Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
Release: com.io7m.jmulticlose 1.1.2
Change: Adjust contract of CloseableCollection.add()
  • Loading branch information
io7m committed Mar 11, 2024
2 parents 8697131 + c1723ff commit d0f7e7d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README-CHANGES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<c:change date="2023-08-13T00:00:00+00:00" summary="Expose collection sizes."/>
</c:changes>
</c:release>
<c:release date="2024-03-11T12:06:16+00:00" is-open="false" ticket-system="com.github.io7m.jmulticlose" version="1.1.1">
<c:release date="2024-03-11T00:00:00+00:00" is-open="false" ticket-system="com.github.io7m.jmulticlose" version="1.1.1">
<c:changes>
<c:change date="2024-03-11T00:00:00+00:00" summary="Fix a minor thread safety issue.">
<c:tickets>
Expand All @@ -29,6 +29,11 @@
</c:change>
</c:changes>
</c:release>
<c:release date="2024-03-11T12:50:08+00:00" is-open="false" ticket-system="com.github.io7m.jmulticlose" version="1.1.2">
<c:changes>
<c:change date="2024-03-11T00:00:00+00:00" summary="Adjust contract of CloseableCollection.add()"/>
</c:changes>
</c:release>
</c:releases>
<c:ticket-systems>
<c:ticket-system default="true" id="com.github.io7m.jmulticlose" url="http://www.github.com/io7m/jmulticlose/issues/"/>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.jmulticlose.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.io7m.jmulticlose</groupId>
<artifactId>com.io7m.jmulticlose</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<artifactId>com.io7m.jmulticlose.core</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ public int size()
@Override
public <T extends AutoCloseable> T add(final T resource)
{
this.stack.push(Objects.requireNonNull(resource, "resource"));
return resource;
if (!this.closed.get()) {
this.stack.push(Objects.requireNonNull(resource, "resource"));
return resource;
}
throw new IllegalStateException("Collection is closed.");
}
}
2 changes: 1 addition & 1 deletion com.io7m.jmulticlose.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.io7m.jmulticlose</groupId>
<artifactId>com.io7m.jmulticlose</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<artifactId>com.io7m.jmulticlose.tests</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ public void testEmpty1()
collection.close();
}

/**
* Adding a resource to a closed collection is not permitted.
*
* @throws IOException On errors
*/

@Test
public void testClosed0()
throws IOException
{
final CloseableCollectionType<IOException> collection =
CloseableCollection.create(IOException::new);

collection.close();
Assertions.assertThrows(IllegalStateException.class, () -> {
collection.add(new Resource(0));
});
}

/**
* Resources are closed.
*
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.io7m.jmulticlose</groupId>
<artifactId>com.io7m.jmulticlose</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>

<packaging>pom</packaging>
<name>com.io7m.jmulticlose</name>
Expand All @@ -27,7 +27,7 @@
</modules>

<properties>
<io7m.api.previousVersion>1.1.0</io7m.api.previousVersion>
<io7m.api.previousVersion>1.1.1</io7m.api.previousVersion>
<io7m.java.targetJavaVersion>17</io7m.java.targetJavaVersion>
</properties>

Expand Down
1 change: 1 addition & 0 deletions spotbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Bug pattern="OPM_OVERLY_PERMISSIVE_METHOD"/>
<Bug pattern="IMC_IMMATURE_CLASS_NO_TOSTRING"/>
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION"/>
<Bug pattern="WEM_WEAK_EXCEPTION_MESSAGING"/>
</Or>
</Match>

Expand Down

0 comments on commit d0f7e7d

Please sign in to comment.