Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore AccessControlException while setting network stack system property #1116

christianbrensing opened this issue Oct 11, 2013 · 2 comments


Copy link

@christianbrensing christianbrensing commented Oct 11, 2013

Since 1.7.5 sets the system property its private method setNetworkStack(). If running with enabled java security (e.g. in a web application) this may fail, if the jruby domain has not been granted the appropiate PropertyPermission.

An easy fix would be to wrap the security related calls in a try-catch-block and ignore or log any thrown AccessControlException.

I made a fix locally, a working patch would look like this:

--- a/core/src/main/java/org/jruby/
+++ b/core/src/main/java/org/jruby/
@@ -131,6 +131,7 @@ import;
 import java.lang.reflect.InvocationTargetException;
 import java.nio.channels.ClosedChannelException;
 import java.util.*;
 import java.util.concurrent.Callable;
@@ -4493,10 +4494,16 @@ public final class Ruby {

     private void setNetworkStack() {
-        if (config.getIPv4Preferred()) {
-            System.setProperty("", "true");
-        } else {
-            System.setProperty("", "false");
+        try {
+            if (config.getIPv4Preferred()) {
+                System.setProperty("", "true");
+            } else {
+                System.setProperty("", "false");
+            }
+        } catch (AccessControlException e) {
+            LOG.debug("unable to set network stack system property due to "
+                    + "security restrictions, please set it manually as JVM "
+                    + "parameter (|false)");
@ghost ghost assigned BanzaiMan Oct 13, 2013
Copy link

@BanzaiMan BanzaiMan commented Oct 13, 2013

Do you mind turning this into a PR? That way, we can credit you for the fix. Thank you.

Copy link

@christianbrensing christianbrensing commented Oct 14, 2013

Done, see PR 1125.

@BanzaiMan BanzaiMan closed this Oct 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants