Bug 41797 - CNFE/NPE thrown from function mapper when externalizing
CNFE/NPE thrown from function mapper when externalizing
Status: CLOSED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Jasper
6.0.10
All All
: P2 major (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
: 42866 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-03-09 01:08 UTC by Tuomas Kiviaho
Modified: 2009-07-18 06:44 UTC (History)
1 user (show)



Attachments
FunctionMapperImpl (760 bytes, patch)
2007-03-09 01:11 UTC, Tuomas Kiviaho
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tuomas Kiviaho 2007-03-09 01:08:21 UTC
ClassNotFoundException is thrown from function mapper when it is (re)mapping a
given class/method name pair back to method instance. This may happen due to
serialization.

Patch is simply to replace used Class.forName with ReflectionUtil.forName 

java.lang.ClassNotFoundException: 
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:164)
	at
org.apache.el.lang.FunctionMapperImpl$Function.getMethod(FunctionMapperImpl.java:147)
	at
org.apache.el.lang.FunctionMapperImpl.resolveFunction(FunctionMapperImpl.java:53)
	at org.apache.el.parser.AstFunction.getValue(AstFunction.java:71)
	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
	at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
Comment 1 Tuomas Kiviaho 2007-03-09 01:11:07 UTC
Created attachment 19687 [details]
FunctionMapperImpl
Comment 2 Tuomas Kiviaho 2007-03-26 23:06:59 UTC
NPE is thrown from function mapper when externalizing second time. First time
loses reference to originating method and second time ignores the fact that
method may indeed still be null.

Patch is to prefer non-transient fields filled during externalization over
method itself.

Caused by: java.lang.NullPointerException
 at
org.apache.el.lang.FunctionMapperImpl$Function.writeExternal(FunctionMapperImpl.java:123)
 at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)
 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1390)
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
 at java.util.HashMap.writeObject(HashMap.java:1000)
 at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
 at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
 at org.apache.el.lang.FunctionMapperImpl.writeExternal(FunctionMapperImpl.java:74)
 at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)
 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1390)
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
 at org.apache.el.ValueExpressionImpl.writeExternal(ValueExpressionImpl.java:256)
 at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)
 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1390)
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
 at
com.sun.facelets.el.TagValueExpression.writeExternal(TagValueExpression.java:128)
Comment 3 Tuomas Kiviaho 2007-03-26 23:09:26 UTC
Comment on attachment 19687 [details]
FunctionMapperImpl

Index:
C:/cygwin/home/kivtuo/scm/tomcat/tc6.0.x/jasper/src/share/org/apache/el/lang/Fu
nctionMapperImpl.java
===================================================================
---
C:/cygwin/home/kivtuo/scm/tomcat/tc6.0.x/jasper/src/share/org/apache/el/lang/Fu
nctionMapperImpl.java	     (revision 416976)
+++
C:/cygwin/home/kivtuo/scm/tomcat/tc6.0.x/jasper/src/share/org/apache/el/lang/Fu
nctionMapperImpl.java	     (working copy)
@@ -119,9 +119,9 @@
	 public void writeExternal(ObjectOutput out) throws IOException {
	     out.writeUTF((this.prefix != null) ? this.prefix : "");
	     out.writeUTF(this.localName);
-	     out.writeUTF(this.m.getDeclaringClass().getName());
-	     out.writeUTF(this.m.getName());
-	    
out.writeObject(ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));
+	     out.writeUTF((this.owner != null) ? this.owner :
this.m.getDeclaringClass().getName());
+	     out.writeUTF((this.name != null) ? this.name : this.m.getName());
+	     out.writeObject((this.types != null) ? this.types :
ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));
	 }

	 /*
@@ -143,7 +143,7 @@
	 public Method getMethod() {
	     if (this.m == null) {
		 try {
-		     Class t = Class.forName(this.owner);
+		     Class t = ReflectionUtil.forName(this.owner);
		     Class[] p = ReflectionUtil.toTypeArray(this.types);
		     this.m = t.getMethod(this.name, p);
		 } catch (Exception e) {
Comment 4 Martyn Hiemstra 2007-09-14 05:25:22 UTC
Over 6 months later!!!! this bug STILL exists in Tomcat 6.0.14. Implement the
fix by Tuomas Kiviaho. It really works.
Comment 5 Tim Funk 2007-09-22 11:06:14 UTC
Patch attached was applied - marking as fixed - please confirm.

Committed revision 578466.
Comment 6 Tuomas Kiviaho 2007-09-22 11:29:02 UTC
The patch editing feature that I used wasn't as clear as it should have been.
This issue is now only partially completed, that is the CNFE has been fixed, but
NPE still remains. Comment number #3 is the result of patch edition containing
both aspects.
Comment 7 Tim Funk 2007-09-23 16:34:49 UTC
Applied the other patch too  - Thanks!

Committed revision 578610.
Comment 8 Tuomas Kiviaho 2007-09-24 06:09:07 UTC
I verified the issue but could not test against a build since there doesn't seem
to be CI oriented mavenization (neither for snapshots nor real versions?). Hence
I don't feel comfortable marking this closed myself without actually testing it
first with a build common for all.
Comment 9 Mark Thomas 2008-01-28 14:06:47 UTC
*** Bug 42866 has been marked as a duplicate of this bug. ***
Comment 10 Konstantin Kolinko 2009-07-18 06:44:14 UTC
Fixed in 6.0.15 (6.0.16). I am changing status from VERIFIED to CLOSED.