@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user