Skip to content

Commit 48a1e82

Browse files
committed
Improving robustness of edge instantiation by making missing source or target non-fatal.
1 parent b3a580c commit 48a1e82

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/main/java/edu/uiowa/slis/graphtaglib

src/main/java/edu/uiowa/slis/graphtaglib/Edge.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ public int doStartTag() throws JspException {
2424

2525
if (theIterator == null) {
2626
logger.trace("Adding edge source: " + source + "\ttarget: " + target + "\tweight: " + weight);
27-
theGraph.addEdge(new GraphEdge(theGraph.getNode(source), theGraph.getNode(target), weight));
27+
GraphNode sourceNode = theGraph.getNode(source);
28+
GraphNode targetNode = theGraph.getNode(target);
29+
if (sourceNode == null) {
30+
logger.error("source node missing for edge <" + source + ", " + target + ">");
31+
} else if (targetNode == null) {
32+
logger.error("target node missing for edge <" + source + ", " + target + ">");
33+
} else
34+
theGraph.addEdge(new GraphEdge(sourceNode, targetNode, weight));
2835
return SKIP_BODY;
2936
} else {
3037
currentEdge = theIterator.currentEdge;

0 commit comments

Comments
 (0)