Uploaded image for project: 'Openfire'
  1. Openfire
  2. OF-1964

SystemProperty should load classes with Thread.getContextClassloader as fallback

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.5.1
    • Fix Version/s: 4.5.2
    • Component/s: None
    • Labels:
      None

      Description

      The new class SystemProperty causes issues, when loading classes which are contained in a plugin.

      In our specific case we have a custom LockOutProvider implementation in a plugin and set this class:

      LockOutManager.LOCKOUT_PROVIDER.setValue(PluginLockoutProvider.class);
      

      The class cannot be found, because SystemProperty is loaded by the App ClassLoader, which doesn't see plugin classes, because Class.forName() only checks the SystemProperty's classloader.

      This is a regression, earlier versions of LockoutManager used the ClassUtils to load LockoutProviders.

      The fix is trivial: SystemProperty should use ClassUtils.forName() instead of Class.forName(), so that Thread.getContextClassLoader() is used as fallback.

      java.lang.ClassNotFoundException: PluginLockoutProvider
              at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
              at java.lang.Class.forName0(Native Method) ~[?:?]
              at java.lang.Class.forName(Class.java:315) ~[?:?]
              at org.jivesoftware.util.SystemProperty.lambda$static$10(SystemProperty.java:101) ~[xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.SystemProperty.getValue(SystemProperty.java:305) [xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.SystemProperty$1.propertySet(SystemProperty.java:198) [xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.PropertyEventDispatcher.dispatchEvent(PropertyEventDispatcher.java:87) [xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.JiveProperties.put(JiveProperties.java:302) [xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.JiveGlobals.setProperty(JiveGlobals.java:833) [xmppserver-4.5.1.jar:4.5.1]
              at org.jivesoftware.util.SystemProperty.setValue(SystemProperty.java:357) [xmppserver-4.5.1.jar:4.5.1]
      
      

        Attachments

          Activity

            People

            Assignee:
            csh csh
            Reporter:
            csh csh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: