Fixes #2069 to catch env var security exception

This commit is contained in:
parrt 2017-10-23 14:40:13 -07:00
parent babf0bfa16
commit aaa4250328
1 changed files with 11 additions and 1 deletions

View File

@ -270,7 +270,7 @@ public class ParserATNSimulator extends ATNSimulator {
public static final boolean retry_debug = false;
/** Just in case this optimization is bad, add an ENV variable to turn it off */
public static final boolean TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT = Boolean.parseBoolean(System.getenv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT"));
public static final boolean TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT = Boolean.parseBoolean(getSafeEnv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT"));
protected final Parser parser;
@ -2181,4 +2181,14 @@ public class ParserATNSimulator extends ATNSimulator {
public Parser getParser() {
return parser;
}
public static String getSafeEnv(String envName) {
try {
return System.getenv(envName);
}
catch(SecurityException e) {
// use the default value
}
return null;
}
}