wonook commented on a change in pull request #241: [NEMO-424] Fix Sonarcloud 
bugs regarding Optional
URL: https://github.com/apache/incubator-nemo/pull/241#discussion_r334262311
 
 

 ##########
 File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/datatransfer/BlockInputReader.java
 ##########
 @@ -67,14 +67,15 @@
 
   @Override
   public List<CompletableFuture<DataUtil.IteratorWithNumBytes>> read() {
-    final Optional<CommunicationPatternProperty.Value> comValue =
+    final Optional<CommunicationPatternProperty.Value> comValueOptional =
       runtimeEdge.getPropertyValue(CommunicationPatternProperty.class);
+    final CommunicationPatternProperty.Value comValue = 
comValueOptional.orElseThrow(IllegalStateException::new);
 
-    if (comValue.get().equals(CommunicationPatternProperty.Value.ONE_TO_ONE)) {
+    if (comValue.equals(CommunicationPatternProperty.Value.ONE_TO_ONE)) {
 
 Review comment:
   I think it would make more sense to rewrite these lines as 
`CommunicationPatternProperty.Value.ONE_TO_ONE.equals(comValue)`, as it would 
prevent null pointer exceptions from happening even if the value of `comValue` 
is null. Same applies to the lines below.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to