File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed
main/java/com/google/gcloud
test/java/com/google/gcloud
main/java/com/google/gcloud/storage
test/java/com/google/gcloud/storage Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 2121import java .io .IOException ;
2222import java .io .Serializable ;
2323import java .nio .ByteBuffer ;
24+ import java .nio .channels .ClosedChannelException ;
2425import java .util .Arrays ;
2526import java .util .Objects ;
2627
@@ -114,9 +115,9 @@ private void flush() {
114115 }
115116 }
116117
117- private void validateOpen () throws IOException {
118+ private void validateOpen () throws ClosedChannelException {
118119 if (!isOpen ) {
119- throw new IOException ( "stream is closed" );
120+ throw new ClosedChannelException ( );
120121 }
121122 }
122123
Original file line number Diff line number Diff line change 3232import java .io .IOException ;
3333import java .io .Serializable ;
3434import java .nio .ByteBuffer ;
35+ import java .nio .channels .ClosedChannelException ;
3536import java .util .Arrays ;
3637import java .util .Random ;
3738
@@ -102,8 +103,7 @@ public void testClose() throws IOException {
102103 @ Test
103104 public void testValidateOpen () throws IOException {
104105 channel .close ();
105- thrown .expect (IOException .class );
106- thrown .expectMessage ("stream is closed" );
106+ thrown .expect (ClosedChannelException .class );
107107 channel .write (ByteBuffer .allocate (42 ));
108108 }
109109
Original file line number Diff line number Diff line change 2929import java .io .IOException ;
3030import java .io .Serializable ;
3131import java .nio .ByteBuffer ;
32+ import java .nio .channels .ClosedChannelException ;
3233import java .util .Map ;
3334import java .util .Objects ;
3435import java .util .concurrent .Callable ;
@@ -55,7 +56,7 @@ class BlobReadChannel implements ReadChannel {
5556 private byte [] buffer ;
5657
5758 BlobReadChannel (StorageOptions serviceOptions , BlobId blob ,
58- Map <StorageRpc .Option , ?> requestOptions ) {
59+ Map <StorageRpc .Option , ?> requestOptions ) {
5960 this .serviceOptions = serviceOptions ;
6061 this .blob = blob ;
6162 this .requestOptions = requestOptions ;
@@ -91,9 +92,9 @@ public void close() {
9192 }
9293 }
9394
94- private void validateOpen () throws IOException {
95+ private void validateOpen () throws ClosedChannelException {
9596 if (!isOpen ) {
96- throw new IOException ( "stream is closed" );
97+ throw new ClosedChannelException ( );
9798 }
9899 }
99100
Original file line number Diff line number Diff line change 3939
4040import java .io .IOException ;
4141import java .nio .ByteBuffer ;
42+ import java .nio .channels .ClosedChannelException ;
4243import java .util .Arrays ;
4344import java .util .Map ;
4445import java .util .Random ;
@@ -156,15 +157,15 @@ public void testClose() {
156157 }
157158
158159 @ Test
159- public void testReadClosed () {
160+ public void testReadClosed () throws IOException {
160161 replay (storageRpcMock );
161162 reader = new BlobReadChannel (options , BLOB_ID , EMPTY_RPC_OPTIONS );
162163 reader .close ();
163164 try {
164165 ByteBuffer readBuffer = ByteBuffer .allocate (DEFAULT_CHUNK_SIZE );
165166 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 ) {
168169 // expected
169170 }
170171 }
You can’t perform that action at this time.
0 commit comments