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

Matthew Swift
02.04.2013 73f7137bbadd359d5106cc5a69cdc3c9f5bedf0c
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
43 ■■■■ changed files
opends/src/server/org/opends/server/admin/ClassPropertyDefinition.java 43 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/ClassPropertyDefinition.java
@@ -347,36 +347,35 @@
   */
  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);
        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);
      Class<?> instanceOfClass = loadClassForValidation(className, i,
          initialize);
      if (!instanceOfClass.isAssignableFrom(theClass)) {
        throw new IllegalPropertyValueException(this, className);
      }
    }
    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);
    }
  }
  /*
   * Do some basic checks to make sure the string representation is valid.
   */