joshelser commented on a change in pull request #746:
URL: https://github.com/apache/hbase/pull/746#discussion_r438509024



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/FSDataInputStreamWrapper.java
##########
@@ -270,39 +267,23 @@ public void unbuffer() {
       if (this.instanceOfCanUnbuffer == null) {
         // To ensure we compute whether the stream is instance of CanUnbuffer 
only once.
         this.instanceOfCanUnbuffer = false;
-        Class<?>[] streamInterfaces = streamClass.getInterfaces();
-        for (Class c : streamInterfaces) {
-          if 
(c.getCanonicalName().toString().equals("org.apache.hadoop.fs.CanUnbuffer")) {
-            try {
-              this.unbuffer = streamClass.getDeclaredMethod("unbuffer");
-            } catch (NoSuchMethodException | SecurityException e) {
-              if (isLogTraceEnabled) {
-                LOG.trace("Failed to find 'unbuffer' method in class " + 
streamClass
-                    + " . So there may be a TCP socket connection "
-                    + "left open in CLOSE_WAIT state.", e);
-              }
-              return;
-            }
-            this.instanceOfCanUnbuffer = true;
-            break;
-          }
+        if (wrappedStream instanceof CanUnbuffer) {
+          this.unbuffer = (CanUnbuffer) wrappedStream;
+          this.instanceOfCanUnbuffer = true;
         }
       }
       if (this.instanceOfCanUnbuffer) {

Review comment:
       I'm really struggling because I don't understand why you don't see the 
same issue I am seeing. Let me try to be super clear. Sorry if I'm missing 
something obvious.
   1. We start this method `unbuffer()` and `instanceOfCanUnbuffer = null`
   2. L260, `getStream()` returns `null` (whether or not this is feasible in 
the code, let's play along)
   3. We immediately go to L275 where `instanceOfCanUnbuffer == null` and we 
throw an NPE.
   3. L261, the `if` block fails, and we do not take it as `stream == null`
   
   Is this code-path flawed?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to