Program: 30291
Project: 30291
Buggy source:
@Test public void testNonCachingNamingObjectFactory(){
  GlassfishNamingManagerImpl nm=null;
  InvocationManager im=new InvocationManagerImpl();
  ComponentInvocation inv=null;
  try {
    InitialContext ic=newInitialContext();
    nm=new GlassfishNamingManagerImpl(ic);
    nm.setInvocationManager(im);
    List<Binding> bindings=new ArrayList<Binding>();
    NamingObjectFactory intFactory=new NamingObjectFactory(){
      private int counter=1;
      public boolean isCreateResultCacheable(){
        return false;
      }
      public Object create(      Context ic){
        return new Integer(++counter);
      }
      public String toString(){
        return "String_Node_Str";
      }
    }
;
    bindings.add(new Binding("String_Node_Str",intFactory));
    bindings.add(new Binding("String_Node_Str","String_Node_Str"));
    nm.bindToComponentNamespace("String_Node_Str","String_Node_Str","String_Node_Str",false,bindings);
    inv=new ComponentInvocation("String_Node_Str",ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,null,null,null);
    im.preInvoke(inv);
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    NamingObjectFactory floatFactory=new NamingObjectFactory(){
      private int counter=1;
      public boolean isCreateResultCacheable(){
        return false;
      }
      public Object create(      Context ic){
        return Float.valueOf(("String_Node_Str" + (++counter)) + "String_Node_Str" + 2323);
      }
      public String toString(){
        return "String_Node_Str";
      }
    }
;
    List<Binding> bindings2=new ArrayList<Binding>();
    bindings2.add(new Binding("String_Node_Str",floatFactory));
    bindings2.add(new Binding("String_Node_Str","String_Node_Str"));
    nm.bindToComponentNamespace("String_Node_Str","String_Node_Str","String_Node_Str",false,bindings2);
    inv=new ComponentInvocation("String_Node_Str",ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,null,null,null);
    im.preInvoke(inv);
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    assert(true);
  }
 catch (  InvocationException inEx) {
    inEx.printStackTrace();
    assert(false);
  }
catch (  Exception ex) {
    ex.printStackTrace();
    assert(false);
  }
 finally {
    try {
      im.postInvoke(inv);
      nm.unbindComponentObjects("String_Node_Str");
    }
 catch (    InvocationException inEx) {
    }
catch (    Exception ex) {
    }
  }
}

Fixed version (ground truth):
@Test public void testNonCachingNamingObjectFactory(){
  GlassfishNamingManagerImpl nm=null;
  InvocationManager im=new InvocationManagerImpl();
  ComponentInvocation inv=null;
  try {
    InitialContext ic=newInitialContext();
    triggerLoadingNamedProxies(ic);
    nm=new GlassfishNamingManagerImpl(ic);
    nm.setInvocationManager(im);
    List<Binding> bindings=new ArrayList<Binding>();
    NamingObjectFactory intFactory=new NamingObjectFactory(){
      private int counter=1;
      public boolean isCreateResultCacheable(){
        return false;
      }
      public Object create(      Context ic){
        return new Integer(++counter);
      }
      public String toString(){
        return "String_Node_Str";
      }
    }
;
    bindings.add(new Binding("String_Node_Str",intFactory));
    bindings.add(new Binding("String_Node_Str","String_Node_Str"));
    nm.bindToComponentNamespace("String_Node_Str","String_Node_Str","String_Node_Str",false,bindings);
    inv=new ComponentInvocation("String_Node_Str",ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,null,null,null);
    im.preInvoke(inv);
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    NamingObjectFactory floatFactory=new NamingObjectFactory(){
      private int counter=1;
      public boolean isCreateResultCacheable(){
        return false;
      }
      public Object create(      Context ic){
        return Float.valueOf(("String_Node_Str" + (++counter)) + "String_Node_Str" + 2323);
      }
      public String toString(){
        return "String_Node_Str";
      }
    }
;
    List<Binding> bindings2=new ArrayList<Binding>();
    bindings2.add(new Binding("String_Node_Str",floatFactory));
    bindings2.add(new Binding("String_Node_Str","String_Node_Str"));
    nm.bindToComponentNamespace("String_Node_Str","String_Node_Str","String_Node_Str",false,bindings2);
    inv=new ComponentInvocation("String_Node_Str",ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,null,null,null);
    im.preInvoke(inv);
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    System.out.println("String_Node_Str" + ic.lookup("String_Node_Str"));
    assert(true);
  }
 catch (  InvocationException inEx) {
    inEx.printStackTrace();
    assert(false);
  }
catch (  Exception ex) {
    ex.printStackTrace();
    assert(false);
  }
 finally {
    try {
      im.postInvoke(inv);
      nm.unbindComponentObjects("String_Node_Str");
    }
 catch (    InvocationException inEx) {
    }
catch (    Exception ex) {
    }
  }
}