You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Stefan (JIRA)" <ji...@apache.org> on 2012/07/20 09:59:34 UTC

[jira] [Updated] (WICKET-4663) LazyInitProxyFactory uses wrong ClassLoader in OSGi environment

     [ https://issues.apache.org/jira/browse/WICKET-4663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan updated WICKET-4663:
---------------------------

    Description: 
The method LazyInitProxyFactory#createProxy use Thread.currentThread().getContextClassLoader() to create a new proxy instance. It seems that this is not correct in an OSGi environment.

Preferred is to use the ClassLoader provided by the AbstractClassResolver class (getClassResolver is not part of IClassResolver). 

Then it will be something like:
{code}
			ClassLoader classLoader;
			if (Application.exists())
			{
				AbstractClassResolver classResolver = (AbstractClassResolver) Application.get()
					.getApplicationSettings()
					.getClassResolver();			

				classLoader = classResolver.getClassLoader();
			}
			else
			{
				classLoader = Thread.currentThread().getContextClassLoader();
			}
			
			try
			{
				return Proxy.newProxyInstance(classLoader, new Class[] { type, Serializable.class,
						ILazyInitProxy.class, IWriteReplace.class }, handler);
			}
{code}

  was:
The method LazyInitProxyFactory#createProxy use Thread.currentThread().getContextClassLoader() to create a new proxy instance. It seems that this is not correct in an OSGi environment.

Preferred is to use the ClassLoader provided by the AbstractClassResolver class (getClassResolver is not part of IClassResolver). 

Then it will be something like:

			ClassLoader classLoader;
			if (Application.exists())
			{
				AbstractClassResolver classResolver = (AbstractClassResolver) Application.get()
					.getApplicationSettings()
					.getClassResolver();			

				classLoader = classResolver.getClassLoader();
			}
			else
			{
				classLoader = Thread.currentThread().getContextClassLoader();
			}
			
			try
			{
				return Proxy.newProxyInstance(classLoader, new Class[] { type, Serializable.class,
						ILazyInitProxy.class, IWriteReplace.class }, handler);
			}

    
> LazyInitProxyFactory uses wrong ClassLoader in OSGi environment
> ---------------------------------------------------------------
>
>                 Key: WICKET-4663
>                 URL: https://issues.apache.org/jira/browse/WICKET-4663
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.7
>            Reporter: Stefan
>
> The method LazyInitProxyFactory#createProxy use Thread.currentThread().getContextClassLoader() to create a new proxy instance. It seems that this is not correct in an OSGi environment.
> Preferred is to use the ClassLoader provided by the AbstractClassResolver class (getClassResolver is not part of IClassResolver). 
> Then it will be something like:
> {code}
> 			ClassLoader classLoader;
> 			if (Application.exists())
> 			{
> 				AbstractClassResolver classResolver = (AbstractClassResolver) Application.get()
> 					.getApplicationSettings()
> 					.getClassResolver();			
> 				classLoader = classResolver.getClassLoader();
> 			}
> 			else
> 			{
> 				classLoader = Thread.currentThread().getContextClassLoader();
> 			}
> 			
> 			try
> 			{
> 				return Proxy.newProxyInstance(classLoader, new Class[] { type, Serializable.class,
> 						ILazyInitProxy.class, IWriteReplace.class }, handler);
> 			}
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira