Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added system property to allow JarMain to not use System.exit in normal flow, this was causing problem when using a service wrapper #22

Merged
merged 1 commit into from

2 participants

@jeffbski

Nick,

I was trying to use a warbled project with the Apache commons-daemon service wrapper in windows which is called procrun.

When the warbled process would exit it was calling System.exit in the normal flow and this was causing an exception for the service wrapper (pipe broken error 109). In searching for the problem, I found that it said any child process should not call System.exit.

So assuming that System.exit is needed in some situations, I added a system property called warbler.skip_system_exit which if defined cause JarMain to not call System.exit in the normal exit flow and this solves the problem for when used with procrun. Thus it could be used with or without System.exit being called depending on whether property is defined.

I did not know how to write a test for this, but I have verified that it solves the problem when I enable the switch.

I also did not build the warbler_jar.jar yet since I had issue getting dev environment setup, so we will need to do that yet for it to take effect.

Feel free to change the property name or whatever you think is best to get this into the JarMain.

Thanks,

Jeff

@jeffbski jeffbski add warbler.skip_system_exit system property which if defined causes …
…JarMain to not use System.exit in the non-error flow. This fixes issue with using a service wrapper like procrun
553cda7
@BanzaiMan
Owner

@jeffbski Sorry that no one responded to this until now. Somewhat incredibly, it appears that we can still merge this. It seems reasonable, and I'd like to merge it. Do you mind adding a test, and perhaps documentation for it?

Thank you.

@jeffbski

@BanzaiMan I wish I could but all my work with that was at my last company and I don't even have a jruby environment setup currently (doing all my current work in node.js).

@BanzaiMan BanzaiMan merged commit 58ecd07 into jruby:master
@BanzaiMan
Owner

OK. I'll see what I can do with regards to documentation. Again, thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2011
  1. @jeffbski

    add warbler.skip_system_exit system property which if defined causes …

    jeffbski authored
    …JarMain to not use System.exit in the non-error flow. This fixes issue with using a service wrapper like procrun
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +10 −1 ext/JarMain.java
View
11 ext/JarMain.java
@@ -128,7 +128,7 @@ public void run() {
public static void main(String[] args) {
try {
int exit = new JarMain(args).start();
- System.exit(exit);
+ if(isSystemExitEnabled()) System.exit(exit);
} catch (Exception e) {
Throwable t = e;
while (t.getCause() != null && t.getCause() != t) {
@@ -145,4 +145,13 @@ public static void main(String[] args) {
private static boolean isDebug() {
return System.getProperty("warbler.debug") != null;
}
+
+ /**
+ * if warbler.skip_system_exit system property is defined, we will not
+ * call System.exit in the normal flow. System.exit can cause problems
+ * for wrappers like procrun
+ */
+ private static boolean isSystemExitEnabled(){
+ return System.getProperty("warbler.skip_system_exit") == null; //omission enables System.exit use
+ }
}
Something went wrong with that request. Please try again.