[ 
https://issues.apache.org/jira/browse/ARIES-2063?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marc-Antoine updated ARIES-2063:
--------------------------------
    Description: 
In legacy code running in an OSGi environment using Aries JNDI, when doing 
`NamingManager.getInitialContext(null).lookup("somejndiurl")` we get 

{quote} 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{quote}


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).

  was:
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).


> 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
>            Priority: Major
>
> In legacy code running in an OSGi environment using Aries JNDI, when doing 
> `NamingManager.getInitialContext(null).lookup("somejndiurl")` we get 
> {quote} 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{quote}
> 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)

Reply via email to