[Bug] ReaderBuilder changes config state during reader creation failure due to server connection failure
rdhabalia opened this issue · comments
Rajan Dhabalia commented
Search before asking
- I searched in the issues and found nothing similar.
Read release policy
- I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
Version
any client version
Minimal reproduce step
@Test
public void createAsyncChangeStateIssue() throws Exception {
ClientBuilder clientBuilder = PulsarClient.builder();
clientBuilder.serviceUrl("pulsar://badUrl");
PulsarClient client = clientBuilder.build();
ReaderBuilder<byte[]> readerBuilder = client.newReader()
.topic("persistent://tenant/ns1/t1").startMessageFromRollbackDuration(100, TimeUnit.SECONDS);
try {
readerBuilder.createAsync().get(1, TimeUnit.SECONDS);
} catch (TimeoutException e) {
log.info("Got expected timeout exception exception, retrying");
// The retry results in an IllegalArgumentException with message:
// Start message id or start message from roll back must be specified
// but they cannot be specified at the same time
readerBuilder.createAsync().get(1, TimeUnit.SECONDS);
}
}
Output:
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Start message id or start message from roll back must be specified but they cannot be specified at the same time
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
Caused by: java.lang.IllegalArgumentException: Start message id or start message from roll back must be specified but they cannot be specified at the same time
at org.apache.pulsar.client.impl.ReaderBuilderImpl.createAsync(ReaderBuilderImpl.java:93)
What did you expect to see?
By any chance if ReaderBuilder fails to create Reader due to connection issue and if application retries then it should not receive java.lang.IllegalArgumentException
because there is no such argument was given to ReaderImpl Builder. Instead Builder should not corrupt the arguments and create Reader to avoid creating lot of objects in memory and avoid memory pressure creation.
What did you see instead?
Client gives java.lang.IllegalArgumentException
even though there is no such illegal argument into the Reader Builder.
Anything else?
No response
Are you willing to submit a PR?
- I'm willing to submit a PR!