Ignore:
Timestamp:
2024-06-13T21:18:45+02:00 (5 months ago)
Author:
taylor.smock
Message:

Cleanup some new PMD warnings from PMD 7.x (followup of r19101)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginClassLoader.java

    r17664 r19106  
    5959        Class<?> result = findLoadedClass(name);
    6060        if (result == null) {
    61             for (PluginClassLoader dep : dependencies) {
    62                 try {
    63                     result = dep.loadClass(name, resolve);
    64                     if (result != null) {
    65                         return result;
    66                     }
    67                 } catch (ClassNotFoundException e) {
    68                     Logging.trace("Plugin class not found in dep {0}: {1}", dep, e.getMessage());
    69                     Logging.trace(e);
    70                 }
    71             }
     61            result = findClassInDependencies(name, resolve);
    7262            try {
    7363                // Will delegate to parent.loadClass(name, resolve) if needed
     
    9383    }
    9484
     85    /**
     86     * Try to find the specified class in this classes dependencies
     87     * @param name The name of the class to find
     88     * @param resolve {@code true} to resolve the class
     89     * @return the class, if found, otherwise {@code null}
     90     */
     91    @SuppressWarnings("PMD.CloseResource") // NOSONAR We do *not* want to close class loaders in this method...
     92    private Class<?> findClassInDependencies(String name, boolean resolve) {
     93        for (PluginClassLoader dep : dependencies) {
     94            try {
     95                Class<?> result = dep.loadClass(name, resolve);
     96                if (result != null) {
     97                    return result;
     98                }
     99            } catch (ClassNotFoundException e) {
     100                Logging.trace("Plugin class not found in dep {0}: {1}", dep, e.getMessage());
     101                Logging.trace(e);
     102            }
     103        }
     104        return null;
     105    }
     106
    95107    @Override
     108    @SuppressWarnings("PMD.CloseResource") // NOSONAR We do *not* want to close class loaders in this method...
    96109    public URL findResource(String name) {
    97110        URL resource = super.findResource(name);
Note: See TracChangeset for help on using the changeset viewer.