New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checker.destroy doesn't erase fileSets but erases everything else #5264

Closed
rnveach opened this Issue Nov 15, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@rnveach
Member

rnveach commented Nov 15, 2017

https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/Checker.java#L173-L176

Checker clears out all other arrays once the destroy method is called, except the list of File Sets.
I don't see a reason to keep them since we erase everything else.
If a Checker instance is used again, it should expect it to be a near clean state.

Should Checker destroy reset everything back to the default like when the check is first instantiated?
If that is the case, the counter is never added back in after the destroy among the other class fields.

This is coming up because I am trying to rewrite the test at

public void testCacheAndCheckWhichAddsNewResourceLocationButKeepsSameCheckerInstance()
for another issue and it uses Checker multiple times.

@rnveach rnveach added the bug label Nov 15, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Nov 15, 2017

Member

If I make the change, the same test I mentioned above fails.

CheckerTest.testCacheAndCheckWhichAddsNewResourceLocationButKeepsSameCheckerInstance:811 Cache has null as a resource key

Member

rnveach commented Nov 15, 2017

If I make the change, the same test I mentioned above fails.

CheckerTest.testCacheAndCheckWhichAddsNewResourceLocationButKeepsSameCheckerInstance:811 Cache has null as a resource key

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 18, 2017

Member

UTs might be created such to reach 100% coverage, so could be a bit weird here.

Member

romani commented Nov 18, 2017

UTs might be created such to reach 100% coverage, so could be a bit weird here.

romani added a commit that referenced this issue Nov 18, 2017

@romani romani added this to the 8.5 milestone Nov 18, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 18, 2017

Member

fix is merged.

Member

romani commented Nov 18, 2017

fix is merged.

@romani romani closed this Nov 18, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment