hashcode is just a cached impl, equals is mandatory because of the hack we have to isolate a bit cxf from apps.
If you fix isolation you can remove it ;). Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau 2013/12/3 Thiago Veronezi <[email protected]>: > The equals and hashCode look weird. > > **************************************** > @Override > public boolean equals(final Object other) { > return other != null && ClassLoader.class.isInstance(other) && > hashCode() == other.hashCode(); > } > > @Override > public int hashCode() { > return hashCode; > } > **************************************** > > I wonder if we need these methods at all. Usually equal hashCodes does not > mean that "equals" is true, right? > > []s, > Thiago. > > > > > On Tue, Dec 3, 2013 at 12:57 PM, <[email protected]> wrote: > >> Author: rmannibucau >> Date: Tue Dec 3 17:57:19 2013 >> New Revision: 1547499 >> >> URL: http://svn.apache.org/r1547499 >> Log: >> correct hashcode in lazywebappclassloader >> >> Modified: >> >> tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/LazyStopWebappClassLoader.java >> >> Modified: >> tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/LazyStopWebappClassLoader.java >> URL: >> http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/LazyStopWebappClassLoader.java?rev=1547499&r1=1547498&r2=1547499&view=diff >> >> ============================================================================== >> --- >> tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/LazyStopWebappClassLoader.java >> (original) >> +++ >> tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/LazyStopWebappClassLoader.java >> Tue Dec 3 17:57:19 2013 >> @@ -41,19 +41,21 @@ public class LazyStopWebappClassLoader e >> private boolean restarting = false; >> private boolean forceStopPhase = >> Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.webappclassloader.force-stop-phase", >> "false")); >> private ClassLoaderConfigurer configurer = null; >> + private final int hashCode; >> >> public LazyStopWebappClassLoader() { >> - construct(); >> + hashCode = construct(); >> } >> >> public LazyStopWebappClassLoader(final ClassLoader parent) { >> super(parent); >> - construct(); >> + hashCode = construct(); >> } >> >> - private void construct() { >> + private int construct() { >> setDelegate(isDelegate()); >> configurer = INIT_CONFIGURER.get(); >> + return super.hashCode(); >> } >> >> @Override >> @@ -211,12 +213,8 @@ public class LazyStopWebappClassLoader e >> } >> >> @Override >> - public int hashCode() { // could be improved a bit adding the host >> and ensuring contextName != null, an alternative is getURLs() but it is >> longer >> - final String name = getContextName(); >> - if (name != null) { >> - return name.hashCode(); >> - } >> - return super.hashCode(); >> + public int hashCode() { >> + return hashCode; >> } >> >> @Override >> >> >>
