@Test void invalid_classpath_element() { File invalidFile = mock(File.class); when(invalidFile.toURI()).thenReturn(URI.create("x: when(javaResourceLocator.classpath()).thenReturn(ImmutableList.of(invalidFile)); final Throwable thrown = catchThrowable(() -> pmdExecutor.execute()); assertThat(thrown) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Classpath"); }
public Report execute() { final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PMD.VERSION); final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); try (URLClassLoader classLoader = createClassloader()) { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); return executePmd(classLoader); } catch (IOException e) { LOGGER.error("Failed to close URLClassLoader.", e); } finally { Thread.currentThread().setContextClassLoader(initialClassLoader); profiler.stopInfo(); } return null; }
PmdExecutor { public Report execute() { final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PMD.VERSION); final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); try (URLClassLoader classLoader = createClassloader()) { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); return executePmd(classLoader); } catch (IOException e) { LOGGER.error("Failed to close URLClassLoader.", e); } finally { Thread.currentThread().setContextClassLoader(initialClassLoader); profiler.stopInfo(); } return null; } }
PmdExecutor { public Report execute() { final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PMD.VERSION); final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); try (URLClassLoader classLoader = createClassloader()) { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); return executePmd(classLoader); } catch (IOException e) { LOGGER.error("Failed to close URLClassLoader.", e); } finally { Thread.currentThread().setContextClassLoader(initialClassLoader); profiler.stopInfo(); } return null; } PmdExecutor(FileSystem fileSystem, RulesProfile rulesProfile, PmdProfileExporter pmdProfileExporter,
                       PmdConfiguration pmdConfiguration, JavaResourceLocator javaResourceLocator, Configuration settings); }
PmdExecutor { public Report execute() { final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PMD.VERSION); final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); try (URLClassLoader classLoader = createClassloader()) { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); return executePmd(classLoader); } catch (IOException e) { LOGGER.error("Failed to close URLClassLoader.", e); } finally { Thread.currentThread().setContextClassLoader(initialClassLoader); profiler.stopInfo(); } return null; } PmdExecutor(FileSystem fileSystem, RulesProfile rulesProfile, PmdProfileExporter pmdProfileExporter,
                       PmdConfiguration pmdConfiguration, JavaResourceLocator javaResourceLocator, Configuration settings); Report execute(); }
PmdExecutor { public Report execute() { final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PMD.VERSION); final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); try (URLClassLoader classLoader = createClassloader()) { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); return executePmd(classLoader); } catch (IOException e) { LOGGER.error("Failed to close URLClassLoader.", e); } finally { Thread.currentThread().setContextClassLoader(initialClassLoader); profiler.stopInfo(); } return null; } PmdExecutor(FileSystem fileSystem, RulesProfile rulesProfile, PmdProfileExporter pmdProfileExporter,
                       PmdConfiguration pmdConfiguration, JavaResourceLocator javaResourceLocator, Configuration settings); Report execute();  }