Skip to content

Commit 6bf0110

Browse files
authored
Merge pull request #1256 from TeamNewPipe/dependabot/gradle/org.mozilla-rhino-1.8.0
Bump org.mozilla:rhino from 1.7.15 to 1.8.0
2 parents aa67363 + da1e0e7 commit 6bf0110

6 files changed

Lines changed: 62 additions & 250 deletions

File tree

extractor/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ checkstyleTest {
2222
enabled false // do not checkstyle test files
2323
}
2424

25+
ext {
26+
rhinoVersion = '1.8.0'
27+
}
28+
2529
dependencies {
2630
implementation project(':timeago-parser')
2731

2832
implementation "com.github.TeamNewPipe:nanojson:$nanojsonVersion"
2933
implementation 'org.jsoup:jsoup:1.18.3'
3034
implementation "com.google.code.findbugs:jsr305:$jsr305Version"
3135

32-
implementation 'org.mozilla:rhino:1.7.15'
36+
implementation "org.mozilla:rhino:$rhinoVersion"
37+
implementation "org.mozilla:rhino-engine:$rhinoVersion"
3338

3439
checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion"
3540

extractor/src/main/java/org/schabi/newpipe/extractor/utils/JavaScript.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,25 @@ private JavaScript() {
1010
}
1111

1212
public static void compileOrThrow(final String function) {
13-
try {
14-
final Context context = Context.enter();
15-
context.setOptimizationLevel(-1);
13+
try (Context context = Context.enter()) {
14+
context.setInterpretedMode(true);
1615

1716
// If it doesn't compile it throws an exception here
1817
context.compileString(function, null, 1, null);
19-
} finally {
20-
Context.exit();
2118
}
2219
}
2320

2421
public static String run(final String function,
2522
final String functionName,
2623
final String... parameters) {
27-
try {
28-
final Context context = Context.enter();
29-
context.setOptimizationLevel(-1);
24+
try (Context context = Context.enter()) {
25+
context.setInterpretedMode(true);
3026
final ScriptableObject scope = context.initSafeStandardObjects();
3127

3228
context.evaluateString(scope, function, functionName, 1, null);
3329
final Function jsFunction = (Function) scope.get(functionName, scope);
3430
final Object result = jsFunction.call(context, scope, scope, parameters);
3531
return result.toString();
36-
} finally {
37-
Context.exit();
3832
}
3933
}
4034

0 commit comments

Comments
 (0)