Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove an optimization in semgrex which may be causing crashes
The optimization removed - if it even does provide a noticeable time benefit - can have repeated IdentityHashMap hashCodes for SemanticGraphs over a long run, leading to crashes when a stale object is retrieved for a new graph. The directed graph now throws a specific exception type when a cyclic graph occurs. Catch exactly that exception in SemgrexMatcher (previous versions caught Exception, which is horrifying)
- Loading branch information
1 parent
755edcf
commit f99b5ab
Showing
4 changed files
with
39 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package edu.stanford.nlp.graph; | ||
|
||
public class CyclicGraphException extends IllegalStateException { | ||
public final String error; | ||
public final DirectedMultiGraph<?, ?> graph; | ||
|
||
public CyclicGraphException(String error, DirectedMultiGraph<?, ?> graph) { | ||
this.error = error; | ||
this.graph = graph; | ||
} | ||
|
||
public String toString() { | ||
return super.toString() + ": " + error + "\nGraph:\n" + graph; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters