Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: gui
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      211

      Description

      Scenario:

      Fresh build, run UC with VPN & Proxy Server
      Click on Portal
      ERROR: "Not able to get hold of installed modules"

      Note that Portal checkbox is checked even though there is no way it can be
      installed. There is a logical error in the code. Here it is simplified from
      UCTableModel.setValueAt()

      setValueAt()
      {
      Set the checkbox to the new value

        Issue Links

          Activity

          Hide
          Byron Nevins added a comment -

          Here is the error in Dep.MgrImpl

          Show
          Byron Nevins added a comment - Here is the error in Dep.MgrImpl
          Hide
          Byron Nevins added a comment -

          Here is the error in Dep.MgrImpl

          Caused by: java.lang.ArrayStoreException
          at java.lang.System.arraycopy(Native Method)
          at java.util.ArrayList.toArray(ArrayList.java:304)
          at
          com.sun.enterprise.update.util.DependencyUtil.getInstalledModules(DependencyUtil.java:279)
          at
          com.sun.enterprise.update.dependency.DependencyManagerImpl.getInstalledModules(DependencyManagerImpl.java:476)
          ... 45 more

          Show
          Byron Nevins added a comment - Here is the error in Dep.MgrImpl Caused by: java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.ArrayList.toArray(ArrayList.java:304) at com.sun.enterprise.update.util.DependencyUtil.getInstalledModules(DependencyUtil.java:279) at com.sun.enterprise.update.dependency.DependencyManagerImpl.getInstalledModules(DependencyManagerImpl.java:476) ... 45 more
          Hide
          Byron Nevins added a comment -
              • Issue 212 has been marked as a duplicate of this issue. ***
          Show
          Byron Nevins added a comment - Issue 212 has been marked as a duplicate of this issue. ***
          Hide
          Byron Nevins added a comment -
              • Issue 213 has been marked as a duplicate of this issue. ***
          Show
          Byron Nevins added a comment - Issue 213 has been marked as a duplicate of this issue. ***
          Hide
          Byron Nevins added a comment -

          Here is what can happen when you do not use generics:

          From DependencyUtil.java

          private static ArrayList getAllModulesInCatalog(Catalog catalog) {
          ArrayList arrayList = new ArrayList();

          if(catalog != null) {
          Module[] module = catalog.getAllModules();
          if (module != null) {
          for(Module m : module)

          { arrayList.add(m); }

          }
          ModuleGroup[] moduleGroup = catalog.getAllModuleGroups();
          if (moduleGroup != null) {
          for (ModuleGroup mg : moduleGroup)

          { getModulesInGroup(arrayList, mg); }

          }
          }

          if (arrayList.size() == 0)

          { arrayList.add(new Module[0]); }

          ---------------------------
          Notice how it adds a Module[] to the ArrayList if there are no modules.
          And it adds a Module to the list if there are modules. Since it is a plain
          ArrayList, there is no compile warnings.

          The calling code does this:

          Module[] array = new Module[modules.size()];
          return (Module[])modules.toArray(array);

          Uh-Oh! ArrayStoreException! You can't cast Module[][] to Module[]

          Moral: If ArrayList<module> was used as the type, I would have saved several
          hours today because the bug would have been, instead, a compile error.

          Show
          Byron Nevins added a comment - Here is what can happen when you do not use generics: From DependencyUtil.java private static ArrayList getAllModulesInCatalog(Catalog catalog) { ArrayList arrayList = new ArrayList(); if(catalog != null) { Module[] module = catalog.getAllModules(); if (module != null) { for(Module m : module) { arrayList.add(m); } } ModuleGroup[] moduleGroup = catalog.getAllModuleGroups(); if (moduleGroup != null) { for (ModuleGroup mg : moduleGroup) { getModulesInGroup(arrayList, mg); } } } if (arrayList.size() == 0) { arrayList.add(new Module[0]); } --------------------------- Notice how it adds a Module[] to the ArrayList if there are no modules. And it adds a Module to the list if there are modules. Since it is a plain ArrayList, there is no compile warnings. The calling code does this: Module[] array = new Module [modules.size()] ; return (Module[])modules.toArray(array); Uh-Oh! ArrayStoreException! You can't cast Module[][] to Module[] Moral: If ArrayList<module> was used as the type, I would have saved several hours today because the bug would have been, instead, a compile error.
          Hide
          Byron Nevins added a comment -

          ...

          Show
          Byron Nevins added a comment - ...
          Hide
          Byron Nevins added a comment -

          I just commented out the bad object addition to the collection.
          The reason is that it's clear from the code that the method used to return a
          zero-length array. Later it was changed to returning a plain ArrayList.
          I left it in there as a comment for future diagnosis if something else breaks.

          Index: src/java/com/sun/enterprise/update/util/DependencyUtil.java
          ===================================================================
          RCS file:
          /cvs/updatecenter/core/src/java/com/sun/enterprise/update/util/DependencyUtil.java,v
          retrieving revision 1.4
          diff -u -r1.4 DependencyUtil.java
          — src/java/com/sun/enterprise/update/util/DependencyUtil.java 17 Feb 2007
          03:06:49 -0000 1.4
          +++ src/java/com/sun/enterprise/update/util/DependencyUtil.java 7 Mar 2007
          02:17:19 -0000
          @@ -323,7 +323,7 @@
          }

          if (arrayList.size() == 0)

          { - arrayList.add(new Module[0]); + //arrayList.add(new Module[0]); }

          return arrayList;

          Show
          Byron Nevins added a comment - I just commented out the bad object addition to the collection. The reason is that it's clear from the code that the method used to return a zero-length array. Later it was changed to returning a plain ArrayList. I left it in there as a comment for future diagnosis if something else breaks. Index: src/java/com/sun/enterprise/update/util/DependencyUtil.java =================================================================== RCS file: /cvs/updatecenter/core/src/java/com/sun/enterprise/update/util/DependencyUtil.java,v retrieving revision 1.4 diff -u -r1.4 DependencyUtil.java — src/java/com/sun/enterprise/update/util/DependencyUtil.java 17 Feb 2007 03:06:49 -0000 1.4 +++ src/java/com/sun/enterprise/update/util/DependencyUtil.java 7 Mar 2007 02:17:19 -0000 @@ -323,7 +323,7 @@ } if (arrayList.size() == 0) { - arrayList.add(new Module[0]); + //arrayList.add(new Module[0]); } return arrayList;

            People

            • Assignee:
              Byron Nevins
              Reporter:
              Byron Nevins
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: