I didn't even realise Wonder had this feature until a couple of days ago: if you're in development mode, launch an app instance on a fixed port, and then later launch another app instance on the same port, Wonder's default behaviour is for the second instance to stop the first (via the stop direct action) and then carry on launching. I had never seen this behaviour before (I regularly see "Address already in use"), and I set out to investigate why.
It seems to be the case that adding WOInject to a Wonder project prevents the catch block here from ever executing:
@Override
public WOAdaptor adaptorWithName(String aClassName, NSDictionary<String, Object> anArgsDictionary) {
try {
return super.adaptorWithName(aClassName, anArgsDictionary);
} catch (NSForwardException e) {
Throwable rootCause = ERXExceptionUtilities.getMeaningfulThrowable(e);
if ((rootCause instanceof BindException) && stopPreviousDevInstance()) {
return super.adaptorWithName(aClassName, anArgsDictionary);
}
throw e;
}
}
Instead of calling stopPreviousDevInstance(), an InjectableApplication logs the exception and then terminates. To reproduce:
- Create a test app from the ERXApplication archetype.
- Launch first and second instances to a fixed port, confirming that second stops first.
- Convert to
InjectableApplication and add ApplicationRunner.
- Launch first and second instances to a fixed port, confirming that second dies with
BindException.
I can't quite see where the exception is being swallowed, and why we don't make it back to the catch block in adaptorWithName().
I didn't even realise Wonder had this feature until a couple of days ago: if you're in development mode, launch an app instance on a fixed port, and then later launch another app instance on the same port, Wonder's default behaviour is for the second instance to stop the first (via the
stopdirect action) and then carry on launching. I had never seen this behaviour before (I regularly see "Address already in use"), and I set out to investigate why.It seems to be the case that adding WOInject to a Wonder project prevents the catch block here from ever executing:
Instead of calling
stopPreviousDevInstance(), anInjectableApplicationlogs the exception and then terminates. To reproduce:InjectableApplicationand addApplicationRunner.BindException.I can't quite see where the exception is being swallowed, and why we don't make it back to the catch block in
adaptorWithName().