| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ | |||
| 21 | 21 | import java.io.IOException; | |
| 22 | 22 | import java.io.Serializable; | |
| 23 | 23 | import java.nio.ByteBuffer; | |
| 24 | + import java.nio.channels.ClosedChannelException; | ||
| 24 | 25 | import java.util.Arrays; | |
| 25 | 26 | import java.util.Objects; | |
| 26 | 27 | ||
@@ -114,9 +115,9 @@ private void flush() { | |||
| 114 | 115 | } | |
| 115 | 116 | } | |
| 116 | 117 | ||
| 117 | - private void validateOpen() throws IOException { | ||
| 118 | + private void validateOpen() throws ClosedChannelException { | ||
| 118 | 119 | if (!isOpen) { | |
| 119 | - throw new IOException("stream is closed"); | ||
| 120 | + throw new ClosedChannelException(); | ||
| 120 | 121 | } | |
| 121 | 122 | } | |
| 122 | 123 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ | |||
| 32 | 32 | import java.io.IOException; | |
| 33 | 33 | import java.io.Serializable; | |
| 34 | 34 | import java.nio.ByteBuffer; | |
| 35 | + import java.nio.channels.ClosedChannelException; | ||
| 35 | 36 | import java.util.Arrays; | |
| 36 | 37 | import java.util.Random; | |
| 37 | 38 | ||
@@ -102,8 +103,7 @@ public void testClose() throws IOException { | |||
| 102 | 103 | @Test | |
| 103 | 104 | public void testValidateOpen() throws IOException { | |
| 104 | 105 | channel.close(); | |
| 105 | - thrown.expect(IOException.class); | ||
| 106 | - thrown.expectMessage("stream is closed"); | ||
| 106 | + thrown.expect(ClosedChannelException.class); | ||
| 107 | 107 | channel.write(ByteBuffer.allocate(42)); | |
| 108 | 108 | } | |
| 109 | 109 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ | |||
| 29 | 29 | import java.io.IOException; | |
| 30 | 30 | import java.io.Serializable; | |
| 31 | 31 | import java.nio.ByteBuffer; | |
| 32 | + import java.nio.channels.ClosedChannelException; | ||
| 32 | 33 | import java.util.Map; | |
| 33 | 34 | import java.util.Objects; | |
| 34 | 35 | import java.util.concurrent.Callable; | |
@@ -55,7 +56,7 @@ class BlobReadChannel implements ReadChannel { | |||
| 55 | 56 | private byte[] buffer; | |
| 56 | 57 | ||
| 57 | 58 | BlobReadChannel(StorageOptions serviceOptions, BlobId blob, | |
| 58 | - Map<StorageRpc.Option, ?> requestOptions) { | ||
| 59 | + Map<StorageRpc.Option, ?> requestOptions) { | ||
| 59 | 60 | this.serviceOptions = serviceOptions; | |
| 60 | 61 | this.blob = blob; | |
| 61 | 62 | this.requestOptions = requestOptions; | |
@@ -91,9 +92,9 @@ public void close() { | |||
| 91 | 92 | } | |
| 92 | 93 | } | |
| 93 | 94 | ||
| 94 | - private void validateOpen() throws IOException { | ||
| 95 | + private void validateOpen() throws ClosedChannelException { | ||
| 95 | 96 | if (!isOpen) { | |
| 96 | - throw new IOException("stream is closed"); | ||
| 97 | + throw new ClosedChannelException(); | ||
| 97 | 98 | } | |
| 98 | 99 | } | |
| 99 | 100 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,7 @@ | |||
| 39 | 39 | ||
| 40 | 40 | import java.io.IOException; | |
| 41 | 41 | import java.nio.ByteBuffer; | |
| 42 | + import java.nio.channels.ClosedChannelException; | ||
| 42 | 43 | import java.util.Arrays; | |
| 43 | 44 | import java.util.Map; | |
| 44 | 45 | import java.util.Random; | |
@@ -156,15 +157,15 @@ public void testClose() { | |||
| 156 | 157 | } | |
| 157 | 158 | ||
| 158 | 159 | @Test | |
| 159 | - public void testReadClosed() { | ||
| 160 | + public void testReadClosed() throws IOException { | ||
| 160 | 161 | replay(storageRpcMock); | |
| 161 | 162 | reader = new BlobReadChannel(options, BLOB_ID, EMPTY_RPC_OPTIONS); | |
| 162 | 163 | reader.close(); | |
| 163 | 164 | try { | |
| 164 | 165 | ByteBuffer readBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); | |
| 165 | 166 | reader.read(readBuffer); | |
| 166 | - fail("Expected BlobReadChannel read to throw IOException"); | ||
| 167 | - } catch (IOException ex) { | ||
| 167 | + fail("Expected BlobReadChannel read to throw ClosedChannelException"); | ||
| 168 | + } catch (ClosedChannelException ex) { | ||
| 168 | 169 | // expected | |
| 169 | 170 | } | |
| 170 | 171 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments