[core] Ignore missing files form auxclasspath

- Resolves #988
This commit is contained in:
Juan Martín Sotuyo Dodero
2018-04-03 02:33:44 -03:00
parent 109c68be4d
commit 8c6688b854
2 changed files with 18 additions and 0 deletions

View File

@ -5,6 +5,7 @@
package net.sourceforge.pmd.cache;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
@ -184,6 +185,8 @@ public abstract class AbstractAnalysisCache implements AnalysisCache {
while (IOUtils.skip(inputStream, Long.MAX_VALUE) == Long.MAX_VALUE) {
// just loop
}
} catch (final FileNotFoundException ignored) {
LOG.warning("Auxclasspath entry " + url.toString() + " doesn't exist, ignoring it");
} catch (final IOException e) {
// Can this even happen?
LOG.log(Level.SEVERE, "Incremental analysis can't check auxclasspath contents", e);

View File

@ -138,6 +138,21 @@ public class FileAnalysisCacheTest {
reloadedCache.isUpToDate(sourceFile));
}
@Test
public void testAuxClasspathNonExistingAuxclasspathEntriesIgnored() throws MalformedURLException, IOException {
final RuleSets rs = mock(RuleSets.class);
final URLClassLoader cl = mock(URLClassLoader.class);
when(cl.getURLs()).thenReturn(new URL[] { new File(tempFolder.getRoot(), "non-existing-dir").toURI().toURL(), });
setupCacheWithFiles(newCacheFile, rs, cl, sourceFile);
final FileAnalysisCache analysisCache = new FileAnalysisCache(newCacheFile);
when(cl.getURLs()).thenReturn(new URL[] {});
analysisCache.checkValidity(rs, cl);
assertTrue("Cache believes unmodified file is not up to date after non-existing auxclasspath entry removed",
analysisCache.isUpToDate(sourceFile));
}
@Test
public void testAuxClasspathChangeWithoutDFAorTypeResolutionDoesNotInvalidatesCache() throws MalformedURLException, IOException {
final RuleSets rs = mock(RuleSets.class);