JDK-6676075 : RegistryContext (com.sun.jndi.url.rmi.rmiURLContext) coding problem
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.naming
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2008-03-17
  • Updated: 2011-02-16
  • Resolved: 2008-06-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10 b26Fixed 7Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
JRE 1.6

A DESCRIPTION OF THE PROBLEM :
There is a problem in the class : [com.sun.jndi.rmi.registry.RegistryContext]

There is a difference on the constructor [public RegistryContext(String s, int i, Hashtable hashtable)] between JRE 1.5 and JRE 1.6

The code is :
    public RegistryContext(String s, int i, Hashtable hashtable)
        throws NamingException
    {
        reference = null;
        environment = hashtable != null ? hashtable : new Hashtable(5);
        if(environment.get("java.naming.rmi.security.manager") != null)
            installSecurityMgr();
        if(s != null && s.charAt(0) == '[')
            s = s.substring(1, s.length() - 1);
        RMIClientSocketFactory rmiclientsocketfactory = (RMIClientSocketFactory)hashtable.get("com.sun.jndi.rmi.factory.socket");
        registry = getRegistry(s, i, rmiclientsocketfactory);
        host = s;
        port = i;
    }


The line added is :
RMIClientSocketFactory rmiclientsocketfactory = (RMIClientSocketFactory)hashtable.get("com.sun.jndi.rmi.factory.socket");

But hashtable can be null and a NullPointerException can appear !!!

Caused by: java.lang.NullPointerException
        at com.sun.jndi.rmi.registry.RegistryContext.<init>(Unknown Source)
        at com.sun.jndi.url.rmi.rmiURLContext.getRootURLContext(Unknown Source)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
        at com.xxx.aes.naming.InitialServerContext.lookup(InitialServerContext.java:131)
        at com.xxx.aes.naming.InitialServerContext.lookup(InitialServerContext.java:159)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at com.xxx.aes.services.resource.Resources.getDataSource(Resources.java:60)
        at com.xxx.aes.services.user.SQLContext.getConnection(SQLContext.java:64)
        at com.xxx.aes.services.user.SQLContext.initialSetting(SQLContext.java:1547)
        at com.xxx.aes.services.user.UserHandler.initialSetting(UserHandler.java:496)
        at com.xxx.aes.services.user.UserHandler.init(UserHandler.java:53)
        at com.xxx.aes.server.UserServer.start(UserServer.java:25)
        at com.xxx.aes.server.ApplicationServer.start(ApplicationServer.java:40)
        at com.xxx.arm.server.ARMServer.start(ARMServer.java:57)
        ... 4 more

The good line code must be :

RMIClientSocketFactory rmiclientsocketfactory = (RMIClientSocketFactory)environment.get("com.sun.jndi.rmi.factory.socket");

Can you fix the bug for the JRE 1.6_05 ?


ERROR MESSAGES/STACK TRACES THAT OCCUR :
NullPointerException

REPRODUCIBILITY :
This bug can be reproduced always.

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION This appears to be a regression introduced with the fix for 5107423.
17-03-2008