mojarra icon indicating copy to clipboard operation
mojarra copied to clipboard

Primitive types cause a NullPointerException in CdiUtils.createConverter

Open balta3 opened this issue 7 years ago • 5 comments

When using a primitive type, I get the following exception in 2.3.4:

Caused by: java.lang.NullPointerException
	at com.sun.faces.cdi.CdiUtils.createConverter(CdiUtils.java:125) ~[javax.faces-2.3.4.jar:2.3.4]

It is working using 2.3.3

balta3 avatar Apr 19 '18 23:04 balta3

IMHO, that looks like a bug that can easily solved. Converting the for look like so should do the trick:

for (
        	Class<?> forClassOrSuperclass = forClass; 
        	managedConverter == null && forClassOrSuperclass != Object.class
                    && forClassOrSuperclass != null;  // <-- add this line 
        	forClassOrSuperclass = forClassOrSuperclass.getSuperclass()
        ) {

Mind you: the type system of Java allows you to use primitive types the same way it allows you to use ordinary objects, pretending primitive type have a type. Of course, that's only a thin layer. It shows when accessing the super class. Usually, it's java.lang.Object, but in the case of primitive types, it's null.

Hope that helps! Stephan

stephanrauh avatar Jun 26 '18 21:06 stephanrauh

This also effects 2.3.5.SP1 shipped with WildFly 13.0.0.Final.

JensPiegsa avatar Jun 30 '18 09:06 JensPiegsa

This problem bothers me too

martin654 avatar Jul 26 '18 09:07 martin654

I am seeing this issue in Wildfly 14 also. Where and how can I apply the fix mentioned above.

lmahadevan avatar Sep 21 '18 16:09 lmahadevan

Created issue at ee4j https://github.com/eclipse-ee4j/mojarra/issues/4500

codylerum avatar Oct 16 '18 15:10 codylerum