You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nemo.apache.org by GitBox <gi...@apache.org> on 2018/06/15 08:11:51 UTC

[GitHub] sanha closed pull request #46: [NEMO-107] SonarCloud Bugs and Vulnerabilities for Nemo Runtime Executor

sanha closed pull request #46: [NEMO-107] SonarCloud Bugs and Vulnerabilities for Nemo Runtime Executor
URL: https://github.com/apache/incubator-nemo/pull/46
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
index 84d4d489..41446c15 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
@@ -428,22 +428,31 @@ public void onOutputContext(final ByteOutputContext outputContext) throws Invali
       @Override
       public void run() {
         try {
-          if (DataStoreProperty.Value.LocalFileStore.equals(blockStore)
-              || DataStoreProperty.Value.GlusterFileStore.equals(blockStore)) {
-            final List<FileArea> fileAreas = ((FileBlock) getBlockStore(blockStore)
-                .readBlock(blockId).get()).asFileAreas(keyRange);
-            for (final FileArea fileArea : fileAreas) {
-              outputContext.newOutputStream().writeFileArea(fileArea).close();
+          final Optional<Block> optionalBlock = getBlockStore(blockStore).readBlock(blockId);
+          if (optionalBlock.isPresent()) {
+            if (DataStoreProperty.Value.LocalFileStore.equals(blockStore)
+                || DataStoreProperty.Value.GlusterFileStore.equals(blockStore)) {
+              final List<FileArea> fileAreas = ((FileBlock) optionalBlock.get()).asFileAreas(keyRange);
+              for (final FileArea fileArea : fileAreas) {
+                try (ByteOutputContext.ByteOutputStream os = outputContext.newOutputStream()) {
+                  os.writeFileArea(fileArea);
+                }
+              }
+            } else {
+              final Iterable<SerializedPartition> partitions = optionalBlock.get().readSerializedPartitions(keyRange);
+              for (final SerializedPartition partition : partitions) {
+                try (ByteOutputContext.ByteOutputStream os = outputContext.newOutputStream()) {
+                  os.writeSerializedPartition(partition);
+                }
+              }
             }
+            handleUsedData(blockStore, blockId);
+            outputContext.close();
+
           } else {
-            final Iterable<SerializedPartition> partitions = getBlockStore(blockStore)
-                .readBlock(blockId).get().readSerializedPartitions(keyRange);
-            for (final SerializedPartition partition : partitions) {
-              outputContext.newOutputStream().writeSerializedPartition(partition).close();
-            }
+            // We don't have the block here...
+            throw new RuntimeException(String.format("Block %s not found in local BlockManagerWorker", blockId));
           }
-          handleUsedData(blockStore, blockId);
-          outputContext.close();
         } catch (final IOException | BlockFetchException e) {
           LOG.error("Closing a block request exceptionally", e);
           outputContext.onChannelError(e);
diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
index 61a371f5..53c03f11 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
@@ -135,6 +135,7 @@ Object fetchDataElement() throws IOException {
         }
       }
     } catch (InterruptedException exception) {
+      Thread.currentThread().interrupt();
       throw new IOException(exception);
     }
   }
diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
index f8ef425e..87f09c09 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
@@ -35,6 +35,7 @@
 import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -209,7 +210,7 @@ public void execute() {
     } catch (Throwable throwable) {
       // ANY uncaught throwable is reported to the master
       taskStateManager.onTaskStateChanged(TaskState.State.FAILED_UNRECOVERABLE, Optional.empty(), Optional.empty());
-      throwable.printStackTrace();
+      LOG.error(ExceptionUtils.getStackTrace(throwable));
     }
   }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services