Skip to content
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

java.util.concurrent.CompletionException: java.lang.NegativeArraySizeException: -1 #2009

Open
maistrovyi opened this issue Jan 13, 2025 Discussed in #1853 · 2 comments
Open

Comments

@maistrovyi
Copy link

maistrovyi commented Jan 13, 2025

Discussed in #1853

Originally posted by maistrovyi May 31, 2024
I'm facing with issue:

Caused by: java.lang.NegativeArraySizeException: -1
	at org.zalando.logbook.httpclient5.LocalRequest$Offering.buffer(LocalRequest.java:85)
	at org.zalando.logbook.httpclient5.LocalRequest.lambda$getBody$3(LocalRequest.java:244)
	at org.zalando.fauxpas.ThrowingFunction.apply(ThrowingFunction.java:19)
	at java.base/java.util.concurrent.atomic.AtomicReference.updateAndGet(AtomicReference.java:210)
	at org.zalando.logbook.httpclient5.LocalRequest.getBody(LocalRequest.java:243)
	at org.zalando.logbook.HttpMessage.getBodyAsString(HttpMessage.java:44)
	at org.zalando.logbook.ForwardingHttpMessage.getBodyAsString(ForwardingHttpMessage.java:47)
	at org.zalando.logbook.FilteredHttpRequest.getBodyAsString(FilteredHttpRequest.java:84)
	at org.zalando.logbook.DefaultHttpLogFormatter.format(DefaultHttpLogFormatter.java:26)
	at org.zalando.logbook.Strategy.write(Strategy.java:69)
	at org.zalando.logbook.DefaultLogbook$1.write(DefaultLogbook.java:43)
	at org.zalando.logbook.httpclient5.LogbookHttpRequestInterceptor.process(LogbookHttpRequestInterceptor.java:25)
	at org.apache.hc.core5.http.protocol.DefaultHttpProcessor.process(DefaultHttpProcessor.java:107)
	at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.produceRequest(HttpAsyncMainClientExec.java:148)
	at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.produceOutput(ClientHttp1StreamHandler.java:183)
	at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.execute(ClientHttp1StreamDuplexer.java:326)
	at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.processCommands(AbstractHttp1StreamDuplexer.java:239)
	at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onConnect(AbstractHttp1StreamDuplexer.java:251)
	at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.connected(AbstractHttp1IOEventHandler.java:55)
	at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.connected(ClientHttp1IOEventHandler.java:41)
	at org.apache.hc.core5.http2.impl.nio.ClientHttp1UpgradeHandler.upgrade(ClientHttp1UpgradeHandler.java:63)
	at org.apache.hc.core5.reactor.InternalDataChannel.switchProtocol(InternalDataChannel.java:420)
	at org.apache.hc.core5.http2.impl.nio.HttpProtocolNegotiator.startProtocol(HttpProtocolNegotiator.java:77)
	at org.apache.hc.core5.http2.impl.nio.HttpProtocolNegotiator.connected(HttpProtocolNegotiator.java:101)
	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:132)
	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
@kasmarian
Copy link
Member

@maistrovyi could you provide more details about the issue? An example repository where it's reproducible would be great to have. As well as Logbook version you used and steps to reproduce.

@maistrovyi
Copy link
Author

maistrovyi commented Jan 15, 2025

@kasmarian hey, for sure, here is our lab
All versions are available in pom.xml, but i've checked that on different versions (same as spring boot 2.7.18 and logbook 2.16.0) - with async httpclient5 behaviour logbook response consuming failed with: java.lang.NegativeArraySizeException: -1

Another point is to update documentation maybe that we mandatory need instantiate HttpContext by ourself like:
client.execute(requestProducer, responseConsumer, HttpClientContext.create(), new FutureCallback...

if no we will faced with: Cannot invoke "org.apache.hc.core5.http.protocol.HttpContext.getAttribute(String)" because "context" is null, what is actually logical.

NB: actually, i've implemented my own temporary solution with custom LogbookAsyncResponseCallback implements FutureCallback<SimpleHttpResponse>, let me know if you need details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants