You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by em...@apache.org on 2019/07/30 21:05:35 UTC

[arrow] branch master updated: ARROW-5996: [Java] Avoid potential resource leak in flight service

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 231101d  ARROW-5996: [Java] Avoid potential resource leak in flight service
231101d is described below

commit 231101d80036744d08d313361de6df46f3d38acf
Author: liyafan82 <fa...@foxmail.com>
AuthorDate: Tue Jul 30 14:04:41 2019 -0700

    ARROW-5996: [Java] Avoid potential resource leak in flight service
    
    1. In FlightService#doPutCustom, the flight stream must be closed, even if an exception is thrown during the call of responseObserver.onError
    2. The exception occurred during the call to acceptPut should not be swallowed.
    
    Closes #4916 from liyafan82/fly_0722_leak and squashes the following commits:
    
    3af5ac905 <liyafan82>  Avoid resource leak in flight service
    
    Authored-by: liyafan82 <fa...@foxmail.com>
    Signed-off-by: Micah Kornfield <em...@gmail.com>
---
 .../main/java/org/apache/arrow/flight/FlightService.java    | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/java/flight/src/main/java/org/apache/arrow/flight/FlightService.java b/java/flight/src/main/java/org/apache/arrow/flight/FlightService.java
index bd83cc6..2b40221 100644
--- a/java/flight/src/main/java/org/apache/arrow/flight/FlightService.java
+++ b/java/flight/src/main/java/org/apache/arrow/flight/FlightService.java
@@ -193,17 +193,16 @@ class FlightService extends FlightServiceImplBase {
             StreamPipe.wrap(responseObserver, PutResult::toProtocol)).run();
         responseObserver.onCompleted();
       } catch (Exception ex) {
-        logger.error("Failed to process custom put.", ex);
         responseObserver.onError(StatusUtils.toGrpcException(ex));
         // The client may have terminated, so the exception here is effectively swallowed.
         // Log the error as well so -something- makes it to the developer.
         logger.error("Exception handling DoPut", ex);
-      }
-      try {
-        fs.close();
-      } catch (Exception e) {
-        logger.error("Exception closing Flight stream", e);
-        throw new RuntimeException(e);
+      } finally {
+        try {
+          fs.close();
+        } catch (Exception e) {
+          logger.error("Exception closing Flight stream", e);
+        }
       }
     });