You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Thomas Watson (JIRA)" <ji...@apache.org> on 2017/04/27 20:01:04 UTC

[jira] [Created] (FELIX-5627) Class loading issues while finding fields causes an NPE

Thomas Watson created FELIX-5627:
------------------------------------

             Summary: Class loading issues while finding fields causes an NPE
                 Key: FELIX-5627
                 URL: https://issues.apache.org/jira/browse/FELIX-5627
             Project: Felix
          Issue Type: Bug
          Components: Declarative Services (SCR)
            Reporter: Thomas Watson


See eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=515873

The following snippet of an NPE can happen

Caused by: java.lang.NullPointerException
	at org.apache.felix.scr.impl.inject.FieldHandler.validateField(FieldHandler.java:279)
	at org.apache.felix.scr.impl.inject.FieldHandler.access$500(FieldHandler.java:51)
	at org.apache.felix.scr.impl.inject.FieldHandler$NotResolved.resolve(FieldHandler.java:839)
	at org.apache.felix.scr.impl.inject.FieldHandler$NotResolved.fieldExists(FieldHandler.java:864)
	at org.apache.felix.scr.impl.inject.FieldHandler.fieldExists(FieldHandler.java:918)

This is because org.apache.felix.scr.impl.inject.FieldHandler.findField(SimpleLogger) can return null.  In this case it is returning null because of a NoClassDefFoundError which is caught in org.apache.felix.scr.impl.inject.FieldHandler.getField(Class<?>, boolean, boolean, SimpleLogger) and null ultimately is returned.  It seems a null check is the correct fix here since later on it appears that null may be used when things are not as expected.

While investigating this issue I found the field handler implementation suffers from the same global lock strategy as the BaseMethod implementation did in FELIX-5615



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)