You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2011/03/27 11:58:36 UTC

svn commit: r1085898 - in /wicket/trunk: wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java

Author: mgrigorov
Date: Sun Mar 27 09:58:36 2011
New Revision: 1085898

URL: http://svn.apache.org/viewvc?rev=1085898&view=rev
Log:
WICKET-3548 Wrong exception type when readResolve fails.

Throw ClassNotFoundException when the class resolving returns 'null' in LazyInitProxyFactory#readResolve().
All other usages of WicketObjects#resolveClass() still just log a warning as before.


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java
    wicket/trunk/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java?rev=1085898&r1=1085897&r2=1085898&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/lang/WicketObjects.java Sun Mar 27 09:58:36 2011
@@ -64,21 +64,24 @@ public class WicketObjects
 	@SuppressWarnings("unchecked")
 	public static <T> Class<T> resolveClass(final String className)
 	{
+		Class<T> resolved = null;
 		try
 		{
 			if (Application.exists())
 			{
-				return (Class<T>)Application.get()
+				resolved = (Class<T>)Application.get()
 					.getApplicationSettings()
 					.getClassResolver()
 					.resolveClass(className);
 			}
-			return (Class<T>)Class.forName(className);
+			resolved = (Class<T>)Class.forName(className, false, Thread.currentThread()
+				.getContextClassLoader());
 		}
 		catch (ClassNotFoundException cnfx)
 		{
-			throw new WicketRuntimeException("Could not resolve class [" + className + "]", cnfx);
+			log.warn("Could not resolve class [" + className + "]", cnfx);
 		}
+		return resolved;
 	}
 
 	/**

Modified: wicket/trunk/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java?rev=1085898&r1=1085897&r2=1085898&view=diff
==============================================================================
--- wicket/trunk/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java (original)
+++ wicket/trunk/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java Sun Mar 27 09:58:36 2011
@@ -32,6 +32,7 @@ import net.sf.cglib.proxy.MethodIntercep
 import net.sf.cglib.proxy.MethodProxy;
 
 import org.apache.wicket.IClusterable;
+import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.util.lang.WicketObjects;
 
@@ -228,6 +229,13 @@ public class LazyInitProxyFactory
 		private Object readResolve() throws ObjectStreamException
 		{
 			Class<?> clazz = WicketObjects.resolveClass(type);
+			if (clazz == null)
+			{
+				ClassNotFoundException cause = new ClassNotFoundException(
+					"Could not resolve type [" + type +
+						"] with the currently configured org.apache.wicket.application.IClassResolver");
+				throw new WicketRuntimeException(cause);
+			}
 			return LazyInitProxyFactory.createProxy(clazz, locator);
 		}
 	}