StructuredExecutor Incompatible with HttpClient?
Alan Bateman
Alan.Bateman at oracle.com
Sun Nov 28 19:55:02 UTC 2021
On 28/11/2021 19:19, Eric Kolotyluk wrote:
> So, main2 seems to work as expected, but main does not
>
> Hello net.kolotyluk.loom.Experiment20_HttpClient
> PID = 35712
> CPU Cores = 12
> Heap Size = 6442450944 bytes
> ______________________________________________________________________________
>
> TimeoutException
>
> Process finished with exit code 130
>
> It hangs indefinitely after TimeoutException, and I have to manually kill
> it. The correct output should be
>
> Hello net.kolotyluk.loom.Experiment20_HttpClient
> PID = 3480
> CPU Cores = 12
> Heap Size = 6442450944 bytes
> ______________________________________________________________________________
>
> early result = {"activity":"Clean out your closet and donate the clothes
> you've
> outgrown","type":"charity","participants":1,"price":0,"link":"","key":"9026787","accessibility":0.1}
> result1 = {"activity":"Clean out your closet and donate the clothes you've
> outgrown","type":"charity","participants":1,"price":0,"link":"","key":"9026787","accessibility":0.1}
> Process finished with exit code 0
I see the the examples are using the HTTP client in async mode and using
the HttpClient.Builder to set the executor for async and dependent
tasks. I assume the HTTP client's "selector manager" is trying to submit
tasks via the execute method but they are being rejected because the
"selector manager" is outside the structure. I need to lookup how to
turn on logging on but I'll bet that is what is going on. So yes, a good
find that it's not suitable for this usage as it's not an Executor
implementation that anyone can ask to execute tasks.
Can you try the HTTP client in synchronous mode? That is what we have
been testing. There was one issue with interruption that was mostly
resolved in Java 16. Using the HTTP client in async mode, without
overriding the executor for the HTTP client to use, should be okay too.
-Alan.
More information about the loom-dev
mailing list