Skip to content

Commit

Permalink
Remove hard-coded suppression of GraalVM warnings in favor of documen…
Browse files Browse the repository at this point in the history
…tation on how to silence them if desired
  • Loading branch information
jbaldassari committed Jul 28, 2023
1 parent f08f9d5 commit 2feb59b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
* <p>
* After creating a {@link ReloadablePacInterpreter}, use the {@link #reload()} method to immediately reload the PAC.
* Alternatively, use the {@link #start(Duration)} method to begin automatic reloads and the {@link #stop()} method to terminate the reload timer.
* </p>
* <p>
* To silence GraalVM warnings set the "polyglot.engine.WarnInterpreterOnly" system property to "false" e.g. -Dpolyglot.engine.WarnInterpreterOnly=false
* </p>
*
* @see "https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file"
* @see "https://www.graalvm.org/latest/reference-manual/js/FAQ/#warning-implementation-does-not-support-runtime-compilation"
*/
public class ReloadablePacInterpreter implements PacInterpreter {
private static final Logger logger = LoggerFactory.getLogger(ReloadablePacInterpreter.class);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/mabl/net/proxy/SimplePacInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

/**
* An interpreter for Proxy Auto-Configuration files/URLs.
* <p>
* To silence GraalVM warnings set the "polyglot.engine.WarnInterpreterOnly" system property to "false" e.g. -Dpolyglot.engine.WarnInterpreterOnly=false
* </p>
*
* @see "https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file"
* @see "https://www.graalvm.org/latest/reference-manual/js/FAQ/#warning-implementation-does-not-support-runtime-compilation"
*/
public class SimplePacInterpreter implements PacInterpreter {
private static final String PAC_UTILS_PATH = "/pacUtils.js";
Expand Down Expand Up @@ -63,9 +67,6 @@ private static String validatePac(final String pac) {

private static Engine initializeEngine() {
return Engine.newBuilder()
// Silence GraalVM warnings
// See: https://www.graalvm.org/latest/reference-manual/js/FAQ/#warning-implementation-does-not-support-runtime-compilation
.option("engine.WarnInterpreterOnly", "false")
.build();
}

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/mabl/net/proxy/PacInterpreterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.undertow.Undertow;
import io.undertow.util.Headers;
import org.junit.After;
import org.junit.Before;

import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -25,6 +26,11 @@ abstract public class PacInterpreterTest {
protected Undertow pacServer;
private volatile String pacServerContent;

@Before
public void silenceGraalvmWarnings() {
System.setProperty("polyglot.engine.WarnInterpreterOnly", Boolean.TRUE.toString());
}

@After
public void tearDown() {
if (pacServer != null) {
Expand Down

0 comments on commit 2feb59b

Please sign in to comment.