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

ArithmeticException "/ by zero" from jetty-util pool #5731

Closed
lachlan-roberts opened this issue Nov 26, 2020 · 5 comments · Fixed by #5732
Closed

ArithmeticException "/ by zero" from jetty-util pool #5731

lachlan-roberts opened this issue Nov 26, 2020 · 5 comments · Fixed by #5732
Assignees
Labels
Bug For general bugs on Jetty side
Milestone

Comments

@lachlan-roberts
Copy link
Contributor

Jetty version
10.0.x

Description
Was working on some WebSocket test and got this error from the ConnectionPool

java.lang.ArithmeticException: / by zero
	at org.eclipse.jetty.util.Pool.acquire(Pool.java:253)
	at org.eclipse.jetty.client.AbstractConnectionPool.activate(AbstractConnectionPool.java:276)
	at org.eclipse.jetty.client.AbstractConnectionPool.acquire(AbstractConnectionPool.java:183)
	at org.eclipse.jetty.client.HttpDestination.process(HttpDestination.java:317)
	at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:306)
	at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:299)
	at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:276)
	at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:253)
	at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:560)
	at org.eclipse.jetty.client.HttpRequest.sendAsync(HttpRequest.java:823)
	at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:810)
	at org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest.send(CoreClientUpgradeRequest.java:197)
	at org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest.sendAsync(CoreClientUpgradeRequest.java:202)
	at org.eclipse.jetty.websocket.core.client.WebSocketCoreClient.connect(WebSocketCoreClient.java:101)
	at org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer.connect(JavaxWebSocketClientContainer.java:133)
	at org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer.connect(JavaxWebSocketClientContainer.java:192)
	at org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer.connectToServer(JavaxWebSocketClientContainer.java:244)
	at org.eclipse.jetty.websocket.javax.tests.server.PrimitivesBinaryEchoTest.testPrimitiveEcho(PrimitivesBinaryEchoTest.java:145)
@lorban
Copy link
Contributor

lorban commented Nov 26, 2020

This can happen when the pool is in the middle of acquiring a connection while another thread removes the last one from the pool.

The fix is to simply add a if (size == 0) return null; check.

@lorban lorban added the Bug For general bugs on Jetty side label Nov 26, 2020
@lorban lorban added this to To Do in Jetty 10.0.0 via automation Nov 26, 2020
@lorban lorban added this to the 10.0.x milestone Nov 26, 2020
Jetty 10.0.0 automation moved this from To Do to Done Nov 26, 2020
@marcphilipp
Copy link
Contributor

marcphilipp commented Dec 17, 2020

Any chance this can get backported to 9.4.x?

@marcphilipp
Copy link
Contributor

I did some digging. Looks like this was broken in ba22c08 which was released in 9.4.32.v20200930.

@lorban Could you please backport this change to 9.4.x? We'll be stuck on JDK 8 for a while and hence cannot upgrade to 10.0.x or 11.0.x.

@joakime
Copy link
Contributor

joakime commented Dec 17, 2020

@marcphilipp the Pool on 9.4.35.v20201120 (which is in maintenance mode) is not the same as the Pool on 10.0.0 (active development branch).
It's a completely different codebase.
This issue isn't really possible on 9.4.x, as the cause of the divide by zero was the result of a throwable from the use of the Trie in 10, (9.4.x's Pool doesn't use Trie)

If you are having an issue, please open a new issue, with the details you are experiencing.

@marcphilipp
Copy link
Contributor

Thanks for the reply! It looked so similar that I apparently didn't look closely enough.

I've now raised #5819 for 9.4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Jetty 10.0.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants