Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5627

Class loading issues while finding fields causes an NPE

    XMLWordPrintableJSON

    Details

      Description

      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

        Attachments

          Activity

            People

            • Assignee:
              cziegeler Carsten Ziegeler
              Reporter:
              tjwatson Tom Watson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: