shinnlok/liferay-portal — pull request #91 by lipusz (2014-11-05 17:11:52+00:00)
Title: [TECH SUPPORT] LPS-51184 Custom DLProcessor is registered as Proxy object: causes ClassCastException when being used.

https://issues.liferay.com/browse/LPS-51184

Hi Shinn,

This is the sequel of https://github.com/shinnlok/liferay-portal/pull/78 --> LPS-49670.

Zsolt's original approach for this issue was to register the unwrapped bean instead of the proxy, but, I believe, it would cause classloader issues later if the container had to reload or access the Class itself (for whatever reason), so our ClassLoaderBeanHandler wasn't invoked to ensure we use the right classLoader.

Let us know if you have any concerns.

BTW: shouldn't we always collect the interfaces from the created instance in ProxyFactory

````java
public static Object newInstance(
ClassLoader classLoader, Class[] interfaceClasses,
String implClassName)
throws Exception {

Object instance = InstanceFactory.newInstance(
classLoader, implClassName);

return ProxyUtil.newProxyInstance(
classLoader, interfaceClasses,
new ClassLoaderBeanHandler(instance, classLoader));
}
````

and merge them with "interfaceClasses" array received as a parameter to create "good" proxies (not to loose behaviors).

Thanks,
Tibor

/cc @zsolah