You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/10/14 17:04:35 UTC

[GitHub] [geode] DonalEvans commented on a change in pull request #5582: GEODE-7864: Fix potential resource leak LGTM warnings

DonalEvans commented on a change in pull request #5582:
URL: https://github.com/apache/geode/pull/5582#discussion_r504835943



##########
File path: geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
##########
@@ -200,21 +200,28 @@ public Object requestToServer(HostAndPort addr, Object request, int timeout,
       out.flush();
 
       if (replyExpected) {
-        DataInputStream in = new DataInputStream(sock.getInputStream());
-        if (debugVersionMessage != null && logger.isDebugEnabled()) {
-          logger.debug(debugVersionMessage);
-        }
-        in = new VersionedDataInputStream(in, serverVersion);
+        DataInputStream in = null;
         try {

Review comment:
       Good catch, thanks.

##########
File path: geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommand.java
##########
@@ -101,26 +101,36 @@ public ResultModel deploy(
     for (DistributedMember member : targetMembers) {
       List<RemoteInputStream> remoteStreams = new ArrayList<>();
       List<String> jarNames = new ArrayList<>();
-      for (String jarFullPath : jarFullPaths) {
-        remoteStreams
-            .add(exporter.export(new SimpleRemoteInputStream(new FileInputStream(jarFullPath))));
-        jarNames.add(FilenameUtils.getName(jarFullPath));
-      }
-
-      // this deploys the jars to all the matching servers
-      ResultCollector<?, ?> resultCollector =
-          executeFunction(this.deployFunction, new Object[] {jarNames, remoteStreams}, member);
-
-      @SuppressWarnings("unchecked")
-      final List<List<Object>> resultCollectorResult =
-          (List<List<Object>>) resultCollector.getResult();
-      results.add(resultCollectorResult.get(0));
+      try {
+        for (String jarFullPath : jarFullPaths) {
+          FileInputStream fileInputStream = null;
+          try {
+            fileInputStream = new FileInputStream(jarFullPath);
+            remoteStreams.add(exporter.export(new SimpleRemoteInputStream(fileInputStream)));
+            jarNames.add(FilenameUtils.getName(jarFullPath));
+          } catch (Exception ex) {
+            if (fileInputStream != null) {
+              fileInputStream.close();

Review comment:
       Fixed




----------------------------------------------------------------
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:
users@infra.apache.org