mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
02.04.2013 972236dbfd47119621074301cc4080b9aab748af
Fix OPENDJ-1079: OpenDJ UpgradeCli adds HTTP connection handler, which breaks Tomcat6 when OpenDJ is an embeddedDS

* refine the class loading exception handling.

1 files modified
37 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/admin/ClassPropertyDefinition.java 37 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/admin/ClassPropertyDefinition.java
@@ -347,32 +347,31 @@
   */
  private Class<?> validateClassInterfaces(String className, boolean initialize)
      throws IllegalPropertyValueException {
    String nvalue = className.trim();
    Class<?> theClass;
    try {
      theClass = loadClass(nvalue, initialize);
    } catch (Throwable t) {
      // If the class cannot be loaded then it is an invalid value.
      throw new IllegalPropertyValueException(this, className, t);
    }
    Class<?> theClass = loadClassForValidation(className, className,
        initialize);
    for (String i : instanceOfInterfaces) {
      try {
        Class<?> instanceOfClass = loadClass(i, initialize);
      Class<?> instanceOfClass = loadClassForValidation(className, i,
          initialize);
        if (!instanceOfClass.isAssignableFrom(theClass)) {
          throw new IllegalPropertyValueException(this, className);
        }
      } catch (Throwable t) {
        /*
         * Should not happen because the class was validated when the property
         * definition was constructed.
         */
        throw new IllegalPropertyValueException(this, className, t);
      }
    return theClass;
    }
    return theClass;
  private Class<?> loadClassForValidation(String componentClassName,
      String classToBeLoaded, boolean initialize) {
    try {
      return loadClass(classToBeLoaded.trim(), initialize);
    } catch (ClassNotFoundException e) {
      // If the class cannot be loaded then it is an invalid value.
      throw new IllegalPropertyValueException(this, componentClassName, e);
    } catch (LinkageError e) {
      // If the class cannot be initialized then it is an invalid value.
      throw new IllegalPropertyValueException(this, componentClassName, e);
    }
  }