Repository navigation
feat(storage): reject fast open configs that are not a single read #14833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fast-open/02-hand-out-first-read
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,6 +268,24 @@ public void readSession_withMoreThanOneFastOpenConfig_isRejected() throws Except | |
| assertThat(requestsReceived).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void readSession_withASeekableChannelConfig_isRejected() throws Exception { | ||
| FakeStorage server = fakeServer(ImmutableMap.of()); | ||
|
|
||
| try (FakeServer fakeServer = FakeServer.of(server); | ||
| Storage storage = fakeServer.getGrpcStorageOptions().getService()) { | ||
| StorageDataClient dataClient = maybeGetStorageDataClient(storage); | ||
|
|
||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> | ||
| dataClient.readSession( | ||
| OPEN, CTX, ImmutableList.of(ReadProjectionConfigs.asSeekableChannel()))); | ||
|
Comment on lines
+279
to
+283
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When asserting that an exception is thrown, it is best practice to also verify the exception message. Since IllegalArgumentException exception = assertThrows(
IllegalArgumentException.class,
() ->
dataClient.readSession(
OPEN, CTX, ImmutableList.of(ReadProjectionConfigs.asSeekableChannel())));
assertThat(exception)
.hasMessageThat()
.contains("a fast open read must be asFutureBytes(), asFutureByteString() or asChannel()");
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: +1 to the |
||
| } | ||
|
|
||
| assertThat(requestsReceived).isEmpty(); | ||
| } | ||
|
|
||
| /** | ||
| * A fake server that answers each request in {@code responses} and adds it to {@link | ||
| * #requestsReceived}. Any other request is answered with an error. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consider
c != null && c.getType() == ProjectionType.STREAM_READso a null element fails cleanly instead of throwing an NPE inside the lambda. Also, aligned with my naming comment on PR #14789,"an initial read must be..."might be clearer than"a fast open read..."when these precondition messages surface to external callers ofStorage.blobReadSession.