[AXIS2-4163] ServiceClient - finalize() method calls super.finalize() too early (original) (raw)

The finalize() method in ServiceClient.java incorrectly calls super.finalize() before cleaning up:

protected void finalize() throws Throwable

{ super.finalize(); cleanup(); }

This leads to EJBClassLoader errors in GlassFish when the garbage collector runs. To fix this, it should be changed to:

// Manual finalizer chaining
@Override protected void finalize() throws Throwable {
try

{ // Finalize subclass state cleanup(); }

finally

{ super.finalize(); }

}

See attached stack trace for details.