[ 
https://issues.apache.org/jira/browse/AVRO-573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877724#action_12877724
 ] 

Jeff Hammerbacher commented on AVRO-573:
----------------------------------------

Let's say, for example, that I have an Avro implementation of an Avro protocol 
that is misbehaving slightly. One of the message implementations declares that 
it throws, for example, an AIOError, but during some processing in that 
message, a RuntimeException (say an NPE) gets thrown. Now, this has never 
happened in my code, because I statically compile future states of the universe 
before shipping. But hypothetically.

In ipc/Responder.java, on line 132, inside of the respond method, we entry a 
try/catch clause. Inside of this try/catch clause, we try calling whichever 
message is indicated by the request. If, in the body of that message, we throw 
an NPE, the catch clause will catch it and record the NPE as the "error" 
variable. Later, in line 149 of the same method, we have an if/else clause. We 
check to ensure the error is not null, and if it is not, we call writeError 
with the "error" variable as the object to be written. Since this object is of 
type NPE, which was not one of the errors declared by the message in the Avro 
protocol, we throw an error while trying to write the error, I think. Which is 
fine; we've now triggered a system error.

Inside of the catch block where we handle system errors, however, I believe 
we're doing something bad: we're creating a new ByteBufferOutputStream bbo, 
which blows away our old bbo. Our old bbo, however, had some useful stuff in it 
that we've failed to recreate: the HandshakeResponse. Thus any client trying to 
read a system error appears SOL

One thing I don't get, and I'm having trouble instrumenting to figure out why 
it is happening because I don't understand Maven, is that the logs write the 
"system error" twice; so somehow, for a single RPC, we're writing this system 
error log entry twice:

{noformat}
10/06/10 22:21:59 WARN ipc.Responder: system error
org.apache.avro.AvroRuntimeException: Not in union 
["string",{"type":"error","name":"AIOError","namespace":"org.apache.hadoop.hbase.avro.generated","fields":[{"name":"message","type":"string"}]}]:
 java.lang.NullPointerException
        at 
org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:340)
        at 
org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
        at 
org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:55)
        at 
org.apache.avro.specific.SpecificResponder.writeError(SpecificResponder.java:81)
        at org.apache.avro.ipc.Responder.respond(Responder.java:137)
        at org.apache.avro.ipc.ResponderServlet.doPost(ResponderServlet.java:48)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
10/06/10 22:21:59 WARN ipc.Responder: system error
org.apache.avro.AvroRuntimeException: Not in union 
["string",{"type":"error","name":"AIOError","namespace":"org.apache.hadoop.hbase.avro.generated","fields":[{"name":"message","type":"string"}]}]:
 java.lang.NullPointerException
        at 
org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:340)
        at 
org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67)
        at 
org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:55)
        at 
org.apache.avro.specific.SpecificResponder.writeError(SpecificResponder.java:81)
        at org.apache.avro.ipc.Responder.respond(Responder.java:137)
        at org.apache.avro.ipc.ResponderServlet.doPost(ResponderServlet.java:48)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
{noformat}

> Uncaught exceptions of an undeclared type are not handled correctly in 
> Responder.java
> -------------------------------------------------------------------------------------
>
>                 Key: AVRO-573
>                 URL: https://issues.apache.org/jira/browse/AVRO-573
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Jeff Hammerbacher
>             Fix For: 1.4.0
>
>
> System error is not handling everything right now. Details in the comments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to