Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays;
import java.util.Objects;

Expand Down Expand Up @@ -114,9 +115,9 @@ private void flush() {
}
}

private void validateOpen() throws IOException {
private void validateOpen() throws ClosedChannelException {
if (!isOpen) {
throw new IOException("stream is closed");
throw new ClosedChannelException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays;
import java.util.Random;

Expand Down Expand Up @@ -102,8 +103,7 @@ public void testClose() throws IOException {
@Test
public void testValidateOpen() throws IOException {
channel.close();
thrown.expect(IOException.class);
thrown.expectMessage("stream is closed");
thrown.expect(ClosedChannelException.class);
channel.write(ByteBuffer.allocate(42));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
Expand All @@ -55,7 +56,7 @@ class BlobReadChannel implements ReadChannel {
private byte[] buffer;

BlobReadChannel(StorageOptions serviceOptions, BlobId blob,
Map<StorageRpc.Option, ?> requestOptions) {
Map<StorageRpc.Option, ?> requestOptions) {
this.serviceOptions = serviceOptions;
this.blob = blob;
this.requestOptions = requestOptions;
Expand Down Expand Up @@ -91,9 +92,9 @@ public void close() {
}
}

private void validateOpen() throws IOException {
private void validateOpen() throws ClosedChannelException {
if (!isOpen) {
throw new IOException("stream is closed");
throw new ClosedChannelException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays;
import java.util.Map;
import java.util.Random;
Expand Down Expand Up @@ -156,15 +157,15 @@ public void testClose() {
}

@Test
public void testReadClosed() {
public void testReadClosed() throws IOException {
replay(storageRpcMock);
reader = new BlobReadChannel(options, BLOB_ID, EMPTY_RPC_OPTIONS);
reader.close();
try {
ByteBuffer readBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE);
reader.read(readBuffer);
fail("Expected BlobReadChannel read to throw IOException");
} catch (IOException ex) {
fail("Expected BlobReadChannel read to throw ClosedChannelException");
} catch (ClosedChannelException ex) {
// expected
}
}
Expand Down