Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve stacktraces for errors from blocking API #538

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented Oct 8, 2018

Blocking API works on top of async API and simply blocks on the returned futures. Exceptions can thus contain stacktraces unrelated to the user's code because they originate from driver worker threads. Such exceptions make it hard for users of the driver to determine what has caused the error.

This PR makes exceptions thrown from blocking API calls contain stacktraces of the current thread. Original async stacktrace is attached in a dummy suppressed exception.

Stacktrace before:

Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: / by zero
	at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:67)
	at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:105)
	at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.unpackFailureMessage(MessageReaderV1.java:83)
	at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.read(MessageReaderV1.java:59)
	at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:83)
	at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:35)
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	... <more netty stacktrace elements>

Stacktrace after:

Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: / by zero
	at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:122)
	at org.neo4j.driver.internal.InternalStatementResult.blockingGet(InternalStatementResult.java:134)
	at org.neo4j.driver.internal.InternalStatementResult.consume(InternalStatementResult.java:117)
	at MyApp.main(MyApp.java:12)
	Suppressed: org.neo4j.driver.internal.util.ErrorUtil$InternalExceptionCause
		at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:67)
		at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:105)
		at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.unpackFailureMessage(MessageReaderV1.java:83)
		at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.read(MessageReaderV1.java:59)
		at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:83)
		at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:35)
		at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
                ... <more netty stacktrace elements>

@lutovich lutovich requested review from zhenlineo and ali-ince October 8, 2018 16:46
Blocking API works on top of async API and simply blocks on the
returned futures. Exceptions can thus contain stacktraces unrelated
to the user's code because they originate from driver worker threads.
Such exceptions make it hard for users of the driver to determine what
has caused the error.

This commit makes exceptions thrown from blocking API calls contain
stacktraces of the current thread. Original async stacktrace is
attached in a dummy suppressed exception.
@lutovich lutovich force-pushed the 1.7-async-stacktraces branch from fb50aa0 to 7a79d06 Compare October 8, 2018 20:44
@ali-ince ali-ince merged commit 346c1d2 into neo4j:1.7 Oct 10, 2018
@lutovich lutovich deleted the 1.7-async-stacktraces branch October 10, 2018 09:48
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants