glassfish
  1. glassfish
  2. GLASSFISH-20948

GlasFish HK2 load class have concurent problem, NullPointException occured while loading class.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: future release
    • Fix Version/s: None
    • Component/s: hk2
    • Labels:
      None
    • Environment:

      GlassFish 3.1.2

      Description

      GlasFish HK2 load class have concurent problem, NullPointException occured while loading class:
      Exception while visiting org/glassfish/gjc/spi/jdbc30/ProfiledConnectionWrapper30.class of size 11160
      java.lang.NullPointerException
      at org.glassfish.hk2.classmodel.reflect.impl.TypesImpl.getType(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.impl.ModelClassVisitor.visit(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.util.JarArchive.onSelectedEntries(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.util.DirectoryArchive.parse(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.util.DirectoryArchive.onSelectedEntries(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Unknown Source)
      at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Unknown Source)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:662)

      The class org.glassfish.hk2.classmodel.reflect.impl.TypesCtr's getHolder method may have concurrent problem, <code>if (unknownTypesStorage.containsKey(name)) </code> is not synchronized, but <code>typeProxy = unknownTypesStorage.remove(name);</code> is synchronized:
      synchronized (unknownTypesStorage)

      { typeProxy = unknownTypesStorage.remove(name); }
      if mutliply threads visit the same class, typeProxy = unknownTypesStorage.remove(name); may return null, caulse NullException occures.

      public <T extends Type> TypeProxy<Type> getHolder(String name, Class<T> type) {
      if (name.equals("java.lang.Object")) return null;
      ConcurrentMap<String, TypeProxy<Type>> typeStorage = storage.get(type);
      if (typeStorage==null) {
      typeStorage = new ConcurrentHashMap<String, TypeProxy<Type>>();
      ConcurrentMap<String, TypeProxy<Type>> old = storage.putIfAbsent(type, typeStorage);
      if (old!=null) { // some other thread got to set that type storage before us, let's use it typeStorage=old; }
      }
      TypeProxy<Type> typeProxy = typeStorage.get(name);
      if (typeProxy ==null) {
      // in our unknown type pool ?
      if (unknownTypesStorage.containsKey(name)) {
      synchronized (unknownTypesStorage) { typeProxy = unknownTypesStorage.remove(name); }

      if (typeProxy!=null) {
      TypeProxy<Type> old = typeStorage.putIfAbsent(name, typeProxy);
      if (old!=null)

      { typeProxy = old; }

      }
      } else {
      typeProxy = new TypeProxy<Type>(null, name);
      TypeProxy<Type> old = typeStorage.putIfAbsent(name, typeProxy);
      if (old==null)

      { nonVisited.push(typeProxy); }

      else

      { typeProxy=old; }

      }
      }
      return typeProxy;
      }

      NullPorintException occures on org.glassfish.hk2.classmodel.reflect.impl.TypesImpl's getType method,<code>TypeProxy<Type> typeProxy = types.getHolder(name, requestedType) </code> may return null:
      public TypeImpl getType(int access, String name, TypeProxy parent) {
      Class<? extends Type> requestedType = getType(access);

      TypeProxy<Type> typeProxy = types.getHolder(name, requestedType);
      synchronized(typeProxy)

      { final Type type = typeProxy.get(); //... omit }

      }

        Activity

        Hide
        guojje added a comment -

        <pre class="java">
        public
        </pre>

        Show
        guojje added a comment - <pre class="java"> public </pre>
        Hide
        reza_rahman added a comment -

        Can you kindly outline the steps to reproduce?

        Show
        reza_rahman added a comment - Can you kindly outline the steps to reproduce?
        Hide
        phil.zampino added a comment -

        This issue appears to have been addressed in later builds of GlassFish 3.1.2. Could you try the latest 3.1.2.2 to confirm if it resolves the problem you're experiencing?

        Show
        phil.zampino added a comment - This issue appears to have been addressed in later builds of GlassFish 3.1.2. Could you try the latest 3.1.2.2 to confirm if it resolves the problem you're experiencing?

          People

          • Assignee:
            phil.zampino
            Reporter:
            hapinwater
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: