diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java index 5d2964775..9e821ab2e 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java @@ -208,6 +208,7 @@ public class Checker extends AutomaticBean for (int i = 0; i < mFileSetChecks.size(); i++) { FileSetCheck fileSetCheck = (FileSetCheck) mFileSetChecks.get(i); fileSetCheck.process(aFiles); + fileSetCheck.destroy(); } int errorCount = mCounter.getCount(); fireAuditFinished(); diff --git a/src/tests/com/puppycrawl/tools/checkstyle/FileSetCheckLifecycleTest.java b/src/tests/com/puppycrawl/tools/checkstyle/FileSetCheckLifecycleTest.java new file mode 100644 index 000000000..4bd9bc98f --- /dev/null +++ b/src/tests/com/puppycrawl/tools/checkstyle/FileSetCheckLifecycleTest.java @@ -0,0 +1,50 @@ +package com.puppycrawl.tools.checkstyle; + +import java.io.File; + +import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; +import com.puppycrawl.tools.checkstyle.api.Configuration; + +public class FileSetCheckLifecycleTest extends BaseCheckTestCase +{ + protected DefaultConfiguration createCheckerConfig(Configuration aCheckConfig) + { + final DefaultConfiguration dc = new DefaultConfiguration("root"); + dc.addChild(aCheckConfig); + return dc; + } + + public static class TestFileSetCheck extends AbstractFileSetCheck + { + private static boolean destroyed = false; + + public void destroy() + { + destroyed = true; + } + + public static boolean isDestroyed() + { + return destroyed; + } + + public void process(File[] aFiles) + { + } + } + + public void testTranslation() + throws Exception + { + Configuration checkConfig = createCheckConfig(TestFileSetCheck.class); + Checker c = createChecker(checkConfig); + final String filepath = getPath("InputScopeAnonInner.java"); + + final String[] expected = { + }; + verify(c, filepath, filepath, expected); + + assertTrue("destroy() not called by Checker", TestFileSetCheck.isDestroyed()); + } + +}