James Birdsall created PROTON-1275:
--------------------------------------
Summary: Proton-J reactor: socket connection interrupt causes
unhandled IllegalArgumentException
Key: PROTON-1275
URL: https://issues.apache.org/jira/browse/PROTON-1275
Project: Qpid Proton
Issue Type: Bug
Components: proton-j
Affects Versions: 0.13.0
Environment: Windows 10
Reporter: James Birdsall
Priority: Minor
IOHandler.handleBound() is trying to make an outbound connection and catches an
IOException. handleBound() then tries to clean up, but the cleanup appears to
assume that some traffic actually occurred, whereas in our case the socket
didn't even connect. This assumption becomes a problem on the last line of the
cleanup:
bq.{{transport.pop(transport.pending()); // Force generation of
TRANSPORT_HEAD_CLOSE (not in C code)}}
...because transport.pending() returns -1, and that -1 eventually becomes the
argument to a call to ByteBuffer.position() and ta da! IllegalArgumentException.
I worked around the problem for the moment by protecting the call to pop():
bq.{{if (transport.pending() >= 0) { transport.pop(transport.pending()); }}}
...and that seems to work fine. The rest of the cleanup may not be necessary in
that particular circumstance but it doesn't seem to do any harm either.
I did the investigation using a copy of qpid-proton master that I grabbed from
github last week, so the line numbers should be pretty close to current.
The call stack from the original IOException, for reference. Reading the docs
on ClosedByInterruptException, it doesn't sound like something that's likely to
happen often. It may be happening to me due to bugs elsewhere in our code. I'm
reporting it despite that because, regardless of why this condition occurs,
when it happens the path between the connection attempt being interrupted and
the unhandled exception is entirely within the Proton-J codebase - it's up to
Proton-J to defend itself against this occurrence.
{quote}
java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(Unknown Source)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at org.apache.qpid.proton.reactor.impl.IOHandler.handleBound(IOHandler.java:155)
at org.apache.qpid.proton.reactor.impl.IOHandler.onUnhandled(IOHandler.java:375)
at
org.apache.qpid.proton.engine.BaseHandler.onConnectionBound(BaseHandler.java:58)
at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:131)
at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
at
org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:307)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:276)
at
com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:355)
at java.lang.Thread.run(Unknown Source)
{quote}
Call stack from the IllegalArgumentException, showing the location of the fatal
call to ByteBuffer.position(-1).
{quote}
java.nio.Buffer.position(Unknown Source)
org.apache.qpid.proton.engine.impl.ssl.SimpleSslTransportWrapper.pop(SimpleSslTransportWrapper.java:413)
org.apache.qpid.proton.engine.impl.ssl.SslImpl$UnsecureClientAwareTransportWrapper.pop(SslImpl.java:185)
org.apache.qpid.proton.engine.impl.TransportImpl.pop(TransportImpl.java:1476)
org.apache.qpid.proton.reactor.impl.IOHandler.handleBound(IOHandler.java:164)
org.apache.qpid.proton.reactor.impl.IOHandler.onUnhandled(IOHandler.java:372)
org.apache.qpid.proton.engine.BaseHandler.onConnectionBound(BaseHandler.java:58)
org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:131)
org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:307)
org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:276)
com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:355)
{quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]