You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/11/10 05:02:23 UTC

[hbase] branch branch-2.4 updated (4605c323ccd -> 32c8dd3c048)

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

zhangduo pushed a change to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


    from 4605c323ccd HBASE-27443 Use java11 in the general check of our jenkins job (#4845)
     new aa8ca7e1b94 HBASE-27473 Fix spotbugs warnings in hbase-rest Client.getResponseBody (#4867)
     new 32c8dd3c048 HBASE-27472 The personality script set wrong hadoop2 check version for branch-2 (#4866)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dev-support/hbase-personality.sh                   |  2 +-
 .../apache/hadoop/hbase/rest/client/Client.java    | 45 ++++++++++++----------
 2 files changed, 25 insertions(+), 22 deletions(-)


[hbase] 01/02: HBASE-27473 Fix spotbugs warnings in hbase-rest Client.getResponseBody (#4867)

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit aa8ca7e1b9496adf4ce6c8f8ef510cca14b3160f
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu Nov 10 12:05:52 2022 +0800

    HBASE-27473 Fix spotbugs warnings in hbase-rest Client.getResponseBody (#4867)
    
    Signed-off-by: Xin Sun <dd...@gmail.com>
    (cherry picked from commit 2d87994f685849219dfde87a111f9f79b6278c17)
---
 .../apache/hadoop/hbase/rest/client/Client.java    | 45 ++++++++++++----------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
index 97586b96825..1475557b633 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.rest.client;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -64,6 +63,9 @@ import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.hbase.thirdparty.com.google.common.io.ByteStreams;
+import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
+
 /**
  * A wrapper around HttpClient which provides some useful function and semantics for interacting
  * with the REST gateway.
@@ -491,29 +493,30 @@ public class Client {
    * @return The response body, null if body is empty
    * @throws IOException If an I/O (transport) problem occurs while obtaining the response body.
    */
-  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE",
-      justification = "null is possible return value")
   public static byte[] getResponseBody(HttpResponse resp) throws IOException {
-    if (resp.getEntity() == null) return null;
-    try (InputStream instream = resp.getEntity().getContent()) {
-      if (instream != null) {
-        long contentLength = resp.getEntity().getContentLength();
-        if (contentLength > Integer.MAX_VALUE) {
-          // guard integer cast from overflow
-          throw new IOException("Content too large to be buffered: " + contentLength + " bytes");
-        }
-        ByteArrayOutputStream outstream =
-          new ByteArrayOutputStream(contentLength > 0 ? (int) contentLength : 4 * 1024);
-        byte[] buffer = new byte[4096];
-        int len;
-        while ((len = instream.read(buffer)) > 0) {
-          outstream.write(buffer, 0, len);
-        }
-        outstream.close();
-        return outstream.toByteArray();
-      }
+    if (resp.getEntity() == null) {
+      return null;
+    }
+    InputStream instream = resp.getEntity().getContent();
+    if (instream == null) {
       return null;
     }
+    try {
+      long contentLength = resp.getEntity().getContentLength();
+      if (contentLength > Integer.MAX_VALUE) {
+        // guard integer cast from overflow
+        throw new IOException("Content too large to be buffered: " + contentLength + " bytes");
+      }
+      if (contentLength > 0) {
+        byte[] content = new byte[(int) contentLength];
+        ByteStreams.readFully(instream, content);
+        return content;
+      } else {
+        return ByteStreams.toByteArray(instream);
+      }
+    } finally {
+      Closeables.closeQuietly(instream);
+    }
   }
 
   /**


[hbase] 02/02: HBASE-27472 The personality script set wrong hadoop2 check version for branch-2 (#4866)

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 32c8dd3c0481976e373881239efdba876ce08046
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu Nov 10 12:13:10 2022 +0800

    HBASE-27472 The personality script set wrong hadoop2 check version for branch-2 (#4866)
    
    Signed-off-by: Xin Sun <dd...@gmail.com>
    (cherry picked from commit 6c32d1a3fb218f3639a6c2037d84624bcf74575a)
---
 dev-support/hbase-personality.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev-support/hbase-personality.sh b/dev-support/hbase-personality.sh
index 5f18b4652af..efe84345f06 100755
--- a/dev-support/hbase-personality.sh
+++ b/dev-support/hbase-personality.sh
@@ -582,7 +582,7 @@ function hadoopcheck_rebuild
     else
       hbase_hadoop2_versions="2.10.0 2.10.1 2.10.2"
     fi
-  elif [[ "${PATCH_BRANCH}" = branch-2.* ]]; then
+  elif [[ "${PATCH_BRANCH}" = branch-2* ]]; then
     yetus_info "Setting Hadoop 2 versions to test based on branch-2.5+ rules."
     hbase_hadoop2_versions="2.10.2"
   else