You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Marc-Antoine (Jira)" <ji...@apache.org> on 2022/01/01 11:25:00 UTC

[jira] [Created] (ARIES-2063) NPE in JNDI service implementation

Marc-Antoine created ARIES-2063:
-----------------------------------

             Summary: NPE in JNDI service implementation
                 Key: ARIES-2063
                 URL: https://issues.apache.org/jira/browse/ARIES-2063
             Project: Aries
          Issue Type: Bug
          Components: JNDI
    Affects Versions: jndi-core-1.0.2
         Environment: org.apache.aries.proxy 1.1.11
org.apache.aries.jndi.core 1.0.2
org.apache.aries.jndi.url 1.1.0
 
Framework is Felix 7.0.1, OS is Windows or Linux.
            Reporter: Marc-Antoine


In legacy code running in an OSGi environment using Aries JNDI, when doing `NamingManager.getInitialContext(null).lookup("somejndiurl")` we get 

```
 java.lang.NullPointerException: null
        at org.apache.aries.jndi.ContextHelper.getContextProvider(ContextHelper.java:158)
        at org.apache.aries.jndi.ContextHelper.getInitialContext(ContextHelper.java:139)
        at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:49)
        at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:730)
mycodehere
```

This is due to an unchecked use of the JNDI `environment` in `ContextHelper.getContextProvider` while it can actually be null as per JNDI spec : `The possibly null environment properties used when creating the context.` (from NamingManager.getInitialContext doc).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)