Skip to content

Commit 713e72e

Browse files
author
Artem Labazin
committed
Add AutoCloseable interface for PooledBytes class
1 parent b05fb5f commit 713e72e

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- Add more tests.
1313
- Add `JavaDoc`.
1414

15+
## [1.17.2](https://github.com/appulse-projects/utils-java/releases/tag/1.17.2) - 2019-12-12
16+
17+
### Changed
18+
19+
- Add `AutoCloseable` interface for `PooledBytes` class.
20+
1521
## [1.17.1](https://github.com/appulse-projects/utils-java/releases/tag/1.17.1) - 2019-12-09
1622

1723
### Changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424

2525
<groupId>io.appulse</groupId>
2626
<artifactId>utils-java</artifactId>
27-
<version>1.17.1</version>
27+
<version>1.17.2</version>
2828
<packaging>jar</packaging>
2929

3030
<properties>
@@ -66,7 +66,7 @@ limitations under the License.
6666
<url>https://github.com/appulse-projects/utils-java</url>
6767
<connection>scm:git:https://github.com/appulse-projects/utils-java.git</connection>
6868
<developerConnection>scm:git:https://github.com/appulse-projects/utils-java.git</developerConnection>
69-
<tag>1.17.1</tag>
69+
<tag>1.17.2</tag>
7070
</scm>
7171

7272
<distributionManagement>

src/main/java/io/appulse/utils/BytesPool.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private Bytes getOrCreateBuffer () throws InterruptedException {
208208
*/
209209
@FieldDefaults(level = PRIVATE)
210210
@SuppressWarnings("PMD.LinguisticNaming")
211-
public class PooledBytes extends BytesAbstract {
211+
public final class PooledBytes extends BytesAbstract implements AutoCloseable {
212212

213213
Bytes delegate;
214214

@@ -226,6 +226,11 @@ public void release () {
226226
BytesPool.this.release(this);
227227
}
228228

229+
@Override
230+
public void close () {
231+
release();
232+
}
233+
229234
@Override
230235
public boolean isAutoResizable () {
231236
validate();

src/test/java/io/appulse/utils/BytesPoolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ void twoPools () {
105105

106106
@Test
107107
void instantiation () {
108-
try (val pool = new BytesPool()) {
109-
val buffer = pool.acquire(16);
108+
try (val pool = new BytesPool();
109+
val buffer = pool.acquire(16)) {
110110
assertThat(buffer.capacity()).isGreaterThanOrEqualTo(16);
111111
}
112112
}

0 commit comments

Comments
 (0)