wonook commented on a change in pull request #247: Fix SonarCloud bugs related
to Optional
URL: https://github.com/apache/incubator-nemo/pull/247#discussion_r339324934
##########
File path: common/src/main/java/org/apache/nemo/common/ir/IRDAG.java
##########
@@ -216,13 +216,15 @@ private void deleteRecursively(final IRVertex
vertexToDelete, final Set<IRVertex
modifiedDAG = builder.buildWithoutSourceSinkCheck();
} else if (vertexToDelete instanceof MessageAggregatorVertex ||
vertexToDelete instanceof TriggerVertex) {
modifiedDAG = rebuildExcluding(modifiedDAG,
vertexGroupToDelete).buildWithoutSourceSinkCheck();
- final int deletedMessageId = vertexGroupToDelete.stream()
+ final Optional<Integer> deletedMessageIdOptional =
vertexGroupToDelete.stream()
.filter(vtd -> vtd instanceof MessageAggregatorVertex)
- .map(vtd -> ((MessageAggregatorVertex)
vtd).getPropertyValue(MessageIdVertexProperty.class).get())
- .findAny().get();
- modifiedDAG.getEdges().stream()
- .filter(e ->
e.getPropertyValue(MessageIdEdgeProperty.class).isPresent())
- .forEach(e ->
e.getPropertyValue(MessageIdEdgeProperty.class).get().remove(deletedMessageId));
+ .map(vtd ->
vtd.getPropertyValue(MessageIdVertexProperty.class).orElseThrow(() ->
+ new RuntimeException("MessageAggregatorVertex " + vtd.getId() + "
does not have MessageIdVertexProperty.")))
Review comment:
Can you throw a designated exception here, instead of using a general one?
----------------------------------------------------------------
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