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

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 @@ -133,12 +133,12 @@ public Tuple<String, byte[]> call() {
if (result.y().length > 0 && lastEtag != null && !Objects.equals(result.x(), lastEtag)) {
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append("Blob ").append(blob).append(" was updated while reading");
throw new StorageException(0, messageBuilder.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this will no longer be retried. Well it shouldn't be so maybe that's not an issue.

throw new IOException(messageBuilder.toString());
}
lastEtag = result.x();
buffer = result.y();
} catch (RetryHelper.RetryHelperException e) {
throw StorageException.translateAndThrow(e);
throw new IOException(e);
}
if (toRead > buffer.length) {
endOfStream = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -71,7 +72,7 @@ public void setUp() {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
verify(rpcFactoryMock, storageRpcMock);
}

Expand Down Expand Up @@ -154,7 +155,7 @@ public void testClose() {
reader = new BlobReadChannel(options, BLOB_ID, EMPTY_RPC_OPTIONS);
assertTrue(reader.isOpen());
reader.close();
assertTrue(!reader.isOpen());
assertFalse(reader.isOpen());
}

@Test
Expand Down Expand Up @@ -190,7 +191,7 @@ public void testReadGenerationChanged() throws IOException {
try {
reader.read(secondReadBuffer);
fail("Expected ReadChannel read to throw StorageException");
} catch (StorageException ex) {
} catch (IOException ex) {
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append("Blob ").append(blobId).append(" was updated while reading");
assertEquals(messageBuilder.toString(), ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1756,22 +1756,22 @@ public void testReadChannelFail() throws IOException {
storage.reader(blob.getBlobId(), Storage.BlobSourceOption.metagenerationMatch(-1L))) {
reader.read(ByteBuffer.allocate(42));
fail("StorageException was expected");
} catch (StorageException ex) {
} catch (IOException ex) {
// expected
}
try (ReadChannel reader =
storage.reader(blob.getBlobId(), Storage.BlobSourceOption.generationMatch(-1L))) {
reader.read(ByteBuffer.allocate(42));
fail("StorageException was expected");
} catch (StorageException ex) {
} catch (IOException ex) {
// expected
}
BlobId blobIdWrongGeneration = BlobId.of(BUCKET, blobName, -1L);
try (ReadChannel reader =
storage.reader(blobIdWrongGeneration, Storage.BlobSourceOption.generationMatch())) {
reader.read(ByteBuffer.allocate(42));
fail("StorageException was expected");
} catch (StorageException ex) {
} catch (IOException ex) {
// expected
}
}
Expand Down Expand Up @@ -1803,7 +1803,7 @@ public void testReadChannelFailUpdatedGeneration() throws IOException {
readBytes = ByteBuffer.allocate(chunkSize);
reader.read(readBytes);
fail("StorageException was expected");
} catch (StorageException ex) {
} catch (IOException ex) {
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append("Blob ").append(blob.getBlobId()).append(" was updated while reading");
assertEquals(messageBuilder.toString(), ex.getMessage());
Expand Down