Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6176305

Creation of a class InitialContext adds not expected values in an environment.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 5.0u1
    • core-libs

      OPERATING SYSTEM(S):
      Microsoft Windows 2000 [Version 5.00.2195]
      Microsoft Windows XP [Version 5.1.2600]

      JAVA VERSION:
      java version "1.5.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b60)
      Java HotSpot(TM) Client VM (build 1.5.0-beta3-b60, mixed mode)


      A DESCRIPTION OF THE PROBLEM :


       After creation of a context at which there is a record,
      with a key equal javax.naming.Context.INITIAL_CONTEXT_FACTORY
      and value equal a class which is inherited from a class javax.naming.spi.InitialContextFactory,
      in this context there is a new not expected record,
      with a key equal javax.naming.Context.STATE_FACTORIES
      and value equal "com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl".


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.util.Hashtable;
      import java.util.Properties;
      import java.util.Enumeration;

      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.spi.InitialContextFactory;


      public class ContextExample implements InitialContextFactory{
          
          
          public Context getInitialContext(Hashtable environment) throws javax.naming.NamingException {
              
              out("getInitialContext Start");
              showEnvironment(environment);
              return new InitialContext();

          }
          
          private void showEnvironment(Hashtable table){
              
              out();
              out("Show Environment");
              
              Enumeration keys = table.keys();
              
              while(keys.hasMoreElements()){
                  Object key = keys.nextElement();
                  
                  Object value = table.get(key);
                  out();
                  out("key = \"" + key + "\"");
                  out("value = \"" + value + "\"");
              }
              out();
              out("End Environment");
              out();
          }
          
          
          private void out(){
              out("------------------------------------------");
          }
          private void out(String msg){
              System.out.println("=== Example: " + msg);
          }
          
          
          public void run(){
              try{
                  
                  Hashtable ENV = new Properties();
                  
                  String key = Context.INITIAL_CONTEXT_FACTORY;
                  String value = this.getClass().getName();
                  out("put key = \"" + key + "\"");
                  out("put value = \"" + value + "\"");
                  ENV.put(key, value);
                  
                  Context ctx = new InitialContext(ENV);
                  
              }catch(Exception e){
                  e.printStackTrace();
              }
          }
              
          
          public static void main(String[] args) {
              new ContextExample().run();
          }
          
      }

      ---------- END SOURCE ----------


      ---------- BEGIN SOURCE OUTPUT----------

      === Example: put key = "java.naming.factory.initial"
      === Example: put value = "ContextExample"
      === Example: getInitialContext Start
      === Example: ------------------------------------------
      === Example: Show Environment
      === Example: ------------------------------------------
      === Example: key = "java.naming.factory.initial"
      === Example: value = "ContextExample"
      === Example: ------------------------------------------
      === Example: key = "java.naming.factory.state"
      === Example: value = "com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl"
      === Example: ------------------------------------------
      === Example: End Environment
      === Example: ------------------------------------------

      ---------- END SOURCE OUTPUT----------


      Run the following script on Windows.
      It is necessary to load attached files one.jar and two.jar
      and set a path to these files in variable JARDIR for start of this test.
      --------SCRIPT START---------------------
      net use M: \\koori\onestop
      set JDK=M:\jdk\1.5.0\promoted\all\b60\binaries\windows-i586

      net use K: \\jtgb4u4c\sail1
      set JCK=K:/testarea/jck1.5/JCK-runtime-15

      set CLASSPATH=%JCK%/classes;%JCK%/lib/javatest.jar
      set JARDIR=.
      set TEST=javasoft.sqe.tests.api.javax.naming.AppResTest


      %JDK%/bin/java -client -cp %CLASSPATH% %TEST% -D %JARDIR%
      --------SCRIPT END----------------------

      TEST OUTPUT:
      ============

      Set classloader to: java.net.FactoryURLClassLoader@11c8a71
      ***InitialContext:java.naming.factory.state has value com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl:jar.state.Factory:jar.state.Factory; expecting jar.state.Factory:jar.state.Factory
      ***InitialDirContext:java.naming.factory.state has value com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl:jar.state.Factory:jar.state.Factory; expecting jar.state.Factory:jar.state.Factory
      ***InitialLdapContext:java.naming.factory.state has value com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl:jar.state.Factory:jar.state.Factory; expecting jar.state.Factory:jar.state.Factory
      Restored classloader to: sun.misc.Launcher$AppClassLoader@12b6651
      resOnly: Failed. first failure: InitialContext:java.naming.factory.state has value com.sun.corba.se.impl.presentation.rmi.JNDIStateFactoryImpl:jar.state.Factory:jar.state.Factory; expecting jar.state.Factory:jar.state.Factory
      ###@###.### 10/8/04 18:08 GMT

            Unassigned Unassigned
            alexsch Alexandr Scherbatiy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: