Commit e2d9cfe
committed
HTTPClient: Don't attempt to process the client if closed
This state check is not sufficent to know if the request has been sent.
If the request has been sent then an error may occur because the ClientHTTPRequest body provider is not resettable.
This can result in an exception like (in the case with a single sized body):
java.util.NoSuchElementException: No elements remaining: 2
org.threadly.util.ArrayIterator.next (ArrayIterator.java:84)
org.threadly.litesockets.protocols.http.request.ClientHTTPRequest.nextBodySection (ClientHTTPRequest.java:65)
org.threadly.litesockets.client.http.HTTPClient.process (HTTPClient.java:416)
org.threadly.litesockets.client.http.HTTPClient.access$1300 (HTTPClient.java:61)
org.threadly.litesockets.client.http.HTTPClient$MainClientProcessor.onClose (HTTPClient.java:595)
org.threadly.litesockets.Client.lambda$callClosers$0 (Client.java:276)
org.threadly.litesockets.Client.runListener (Client.java:294)
org.threadly.litesockets.Client.callClosers (Client.java:273)
org.threadly.litesockets.TCPClient.lambda$close$0 (TCPClient.java:173)
org.threadly.concurrent.wrapper.KeyDistributedExecutor$TaskQueueWorker.runTask (KeyDistributedExecutor.java:448)
org.threadly.concurrent.wrapper.KeyDistributedExecutor$TaskQueueWorker.run (KeyDistributedExecutor.java:502)
org.threadly.concurrent.AbstractPriorityScheduler$OneTimeTaskWrapper.runTask (AbstractPriorityScheduler.java:715)
org.threadly.concurrent.PriorityScheduler$Worker.executeTasksWhileRunning (PriorityScheduler.java:956)
org.threadly.concurrent.PriorityScheduler$Worker.run (PriorityScheduler.java:963)
java.lang.Thread.run (Thread.java:834)
Since the body may be sourced from an InputStream or other means which can't be retried by the library, retry logic needs to be done at the library user level.
This change will instead just communicate the connection close error out so it can be retried there.1 parent dfcc68d commit e2d9cfe
File tree
1 file changed
+1
-4
lines changed- client/src/main/java/org/threadly/litesockets/client/http
1 file changed
+1
-4
lines changedLines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
593 | 592 | | |
594 | | - | |
595 | | - | |
596 | | - | |
| 593 | + | |
597 | 594 | | |
598 | 595 | | |
599 | 596 | | |
| |||
0 commit comments