Skip to content

Commit

Permalink
add config to control close parser on stop or not
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglingsong committed Jul 21, 2021
1 parent 8d28d6b commit 1302e69
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public int compare(IndefinitePathBinding o1, IndefinitePathBinding o2) {
private int maxDepth = -1;
private boolean skipOverlappedPath = false;
private boolean hasFilter = false;
private boolean closeParserOnStop = true;

private Binding[][] definitePathLookup;

Expand Down Expand Up @@ -387,4 +388,12 @@ public boolean hasFilter() {
return hasFilter;
}

public void setCloseParserOnStop(boolean closeParserOnStop) {
this.closeParserOnStop = closeParserOnStop;
}

public boolean isCloseParserOnStop() {
return closeParserOnStop;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void doParse() {
context.primitive(staticPrimitiveHolder.withValue(tempString));
}

if (context.isStopped()) {
if (context.getConfig().isCloseParserOnStop() && context.isStopped()) {
lexer.close();
}

Expand Down
2 changes: 1 addition & 1 deletion jsurfer-gson/src/main/java/org/jsfr/json/GsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void doParse() {
break;
}
}
if (context.isStopped()) {
if (context.getConfig().isCloseParserOnStop() && context.isStopped()) {
jsonReader.close();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void doPare() throws IOException {
throw new IllegalStateException("Unexpected token");
}
}
if (context.isStopped()) {
if (context.getConfig().isCloseParserOnStop() && context.isStopped()) {
this.jsonParser.close();
}
}
Expand Down

0 comments on commit 1302e69

Please sign in to comment.