This is an automated email from the ASF dual-hosted git repository.

jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new d532441  THRIFT-4368: Fix guaranteed NPE in TBaseAsyncProcessor.java
d532441 is described below

commit d5324413664a44da1cbdf671e0fe00b8571c2b4b
Author: Beluga Behr <dam6...@gmail.com>
AuthorDate: Fri Jan 4 10:30:32 2019 -0500

    THRIFT-4368: Fix guaranteed NPE in TBaseAsyncProcessor.java
    
    wq# Please enter the commit message for your changes. Lines starting
---
 lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java 
b/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java
index 9459c1a..0ab1827 100644
--- a/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java
+++ b/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java
@@ -54,8 +54,13 @@ public class TBaseAsyncProcessor<I> implements 
TAsyncProcessor, TProcessor {
         if (fn == null) {
             TProtocolUtil.skip(in, TType.STRUCT);
             in.readMessageEnd();
-            if (!fn.isOneway()) {
-              TApplicationException x = new 
TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method 
name: '"+msg.name+"'");
+
+            TApplicationException x = new 
TApplicationException(TApplicationException.UNKNOWN_METHOD,
+                "Invalid method name: '" + msg.name + "'");
+            LOGGER.debug("Invalid method name", x);
+
+            // this means it is a two-way request, so we can send a reply
+            if (msg.type == TMessageType.CALL) {
               out.writeMessageBegin(new TMessage(msg.name, 
TMessageType.EXCEPTION, msg.seqid));
               x.write(out);
               out.writeMessageEnd();
@@ -72,8 +77,12 @@ public class TBaseAsyncProcessor<I> implements 
TAsyncProcessor, TProcessor {
             args.read(in);
         } catch (TProtocolException e) {
             in.readMessageEnd();
+
+            TApplicationException x = new 
TApplicationException(TApplicationException.PROTOCOL_ERROR,
+                e.getMessage());
+            LOGGER.debug("Could not retrieve function arguments", x);
+
             if (!fn.isOneway()) {
-              TApplicationException x = new 
TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
               out.writeMessageBegin(new TMessage(msg.name, 
TMessageType.EXCEPTION, msg.seqid));
               x.write(out);
               out.writeMessageEnd();
@@ -93,6 +102,7 @@ public class TBaseAsyncProcessor<I> implements 
TAsyncProcessor, TProcessor {
         try {
           fn.start(iface, args, resultHandler);
         } catch (Exception e) {
+          LOGGER.debug("Exception handling function", e);
           resultHandler.onError(e);
         }
         return true;

Reply via email to