spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Class.equals returns false in some cases with spring-boot-dev-tools activated

Open bfortunato opened this issue 9 years ago • 3 comments

Probably because of ReloaderClassLoader, in some cases there are classes that appears equals that are loaded by a different class loader.

If i store a reference of class type into a singleton bean and compare with the same class using equals(), the result is false.

es: @Component class SingletonBean() { public Class getClassType() { return MyClass.class } }

somewhere in code, for example a controller

applicationContext.getBean(SingletonBean.class).getClassType().equals(MyClass.class)

returns false

If I check the classloader of each class, in the first case is ReloaderClassLoader, in second case is AppLauncher$ClassLoader.

bfortunato avatar Dec 06 '16 18:12 bfortunato

Sounds like you need to configure some of your dependencies to be loaded by the restart class loader. The documentation describes how to do it.

wilkinsona avatar Dec 06 '16 19:12 wilkinsona

Tnx for the quick response. It's not the case that the documentation describe. Both classes are in the same module and a single class is loaded into 2 class loaders. If this is normal, I'll check my configuration

bfortunato avatar Dec 07 '16 08:12 bfortunato

We can investigate a bit more, but we'll need some more information. If you provide a sample that reproduces the problem we can take another look.

wilkinsona avatar Dec 07 '16 08:12 wilkinsona