Skip to content

WOInject seems to break ERXApplication.stopPreviousDevInstance() #20

Description

@paulhoadley

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:

  1. Create a test app from the ERXApplication archetype.
  2. Launch first and second instances to a fixed port, confirming that second stops first.
  3. Convert to InjectableApplication and add ApplicationRunner.
  4. 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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions