Skip to content

Commit

Permalink
fix 134: replace AutoCloseable with Closeable (#135)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
  • Loading branch information
anthony-swirldslabs authored Dec 4, 2023
1 parent 4823362 commit 5ea94d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.hedera.pbj.runtime.io.ReadableSequentialData;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.BufferUnderflowException;
Expand All @@ -15,7 +16,7 @@
* <p>A {@code ReadableSequentialData} backed by an input stream. If the instance is closed,
* the underlying {@link InputStream} is closed too.
*/
public class ReadableStreamingData implements ReadableSequentialData, AutoCloseable {
public class ReadableStreamingData implements ReadableSequentialData, Closeable {

/** The underlying input stream */
private final InputStream in;
Expand All @@ -36,7 +37,7 @@ public ReadableStreamingData(@NonNull final InputStream in) {
}

// ================================================================================================================
// AutoCloseable Methods
// Closeable Methods

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.hedera.pbj.runtime.io.DataAccessException;
import com.hedera.pbj.runtime.io.WritableSequentialData;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.BufferOverflowException;
Expand All @@ -13,7 +14,7 @@
* <p>A {@code WritableSequentialData} backed by an output stream. If the instance is closed,
* the underlying {@link OutputStream} is closed too.
*/
public class WritableStreamingData implements WritableSequentialData, AutoCloseable {
public class WritableStreamingData implements WritableSequentialData, Closeable {

/** The underlying output stream */
private final OutputStream out;
Expand Down Expand Up @@ -46,7 +47,7 @@ public WritableStreamingData(@NonNull final OutputStream out, final long capacit
}

// ================================================================================================================
// AutoCloseable Methods
// Closeable Methods

@Override
public void close() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected byte[] extractWrittenBytes(@NonNull WritableSequentialData seq) {

@Test
@DisplayName("capacity() returns Long.MAX_VALUE by default")
void defaultCapacity() throws Exception {
void defaultCapacity() throws IOException {
// Given a sequence
try (final var seq = sequence()) {
// When we ask for the capacity, then we get Long.MAX_VALUE
Expand All @@ -56,7 +56,7 @@ void defaultCapacity() throws Exception {

@Test
@DisplayName("capacity() returns the capacity specified in the constructor")
void specifiedCapacity() throws Exception {
void specifiedCapacity() throws IOException {
// Given a sequence
try (final var seq = new WritableStreamingData(new ByteArrayOutputStream(), 10)) {
// When we ask for the capacity, then we get 10
Expand Down

0 comments on commit 5ea94d1

Please sign in to comment.