CPD Results

The following document contains the results of PMD's CPD 6.46.0.

Duplications

File Line
org/restheart/plugins/PluginsFactory.java 355
org/restheart/plugins/PluginsFactory.java 428
.filter(p -> p.methodHash == injection.methodHash).count() == 1) {

                // check configuration scope
                var allConfScope = injection.params.stream()
                        .anyMatch(p -> "scope".equals(p.getKey())
                                && (ConfigurationScope.class.getName() + "." + ConfigurationScope.ALL.name())
                                        .equals(p.getValue().toString()));

                var scopedConf = (Map) (allConfScope ? Bootstrapper.getConfiguration().toMap()
                        : ip.confs != null ? ip.confs.get(ip.name) : null);

                if (scopedConf == null) {
                    LOGGER.warn(
                            "{} {} defines method {} with @InjectConfiguration " + "but no configuration found for it",
                            ip.type, ip.name, injection.method);
                }

                // try to inovke @InjectConfiguration method
                try {
                    ip.clazz.getDeclaredMethod(injection.method, Map.class).invoke(ip.instance, scopedConf);
File Line
org/restheart/plugins/PluginsFactory.java 294
org/restheart/plugins/PluginsFactory.java 316
invokeCoreInjectMethods(ip);
            } catch (InvocationTargetException ite) {
                if (ite.getCause() != null && ite.getCause() instanceof NoClassDefFoundError) {
                    var errMsg = "Error handling the request. " + "An external dependency is missing for " + ip.type
                            + " " + ip.name + ". Copy the missing dependency jar to the plugins directory "
                            + "to add it to the classpath";

                    LOGGER.error(errMsg, ite);
                } else {
                    LOGGER.error("Error injecting dependency to {} {}: {}", ip.type, ip.name,
                            getRootException(ite).getMessage(), ite);
                }
            } catch (ConfigurationException | InstantiationException | IllegalAccessException ex) {
                LOGGER.error("Error injecting dependency to {} {}: {}", ip.type, ip.name,
                        getRootException(ex).getMessage(), ex);
            }
        }
    }
File Line
org/restheart/Bootstrapper.java 523
org/restheart/Bootstrapper.java 565
.filter(i -> initPoint(i.getInstance()) == BEFORE_STARTUP)
            .forEach(i -> {
                try {
                    i.getInstance().init();
                } catch (NoClassDefFoundError iae) {
                    // this occurs executing interceptors missing external dependencies
                    LOGGER.error("Error executing initializer {}. An external dependency is missing. Copy the missing dependency jar to the plugins directory to add it to the classpath", i.getName(), iae);
                } catch (LinkageError le) {
                    // this occurs executing plugin code compiled
                    // with wrong version of restheart-commons

                    var version = Version.getInstance().getVersion() == null
                        ? "of correct version"
                        : "v" + Version.getInstance().getVersion();

                    LOGGER.error("Linkage error executing initializer {}. Check that it was compiled against restheart-commons {}", i.getName(), version, le);
                } catch (Throwable t) {
                    LOGGER.error("Error executing initializer {}", i.getName());