jenkinsci / lib-file-leak-detector

Java agent that detects file handle leak
http://file-leak-detector.kohsuke.org/
MIT License
238 stars 112 forks source link

Adapting compatibility for Mockito upgrade and vararg breaking change #129

Closed aneveux closed 1 year ago

aneveux commented 1 year ago

Hello :wave:

Sorry for dropping here unexpected, @basil shared a small challenge after a presentation for participants to identify the cause of this test failure, and here I am :smile:

The test failure was caused by https://github.com/mockito/mockito/commit/064fe9028993a11ccf0ae12b5975b96baffcf305 which introduces a breaking change related to how varargs are managed:

BREAKING CHANGE: This changes the default behaviour of the any() matcher, argument captors and MockitoHamcrest matchers when passed to a varargs parameter. Previously, these matcher would match each element in the varargs parameter, matching any number of elements 0...n. From Mockito v5 onwards, when passed to a varargs parameter, will match invocations where a single value is passed to the varargs parameter. To match any number of values passed to the varargs parameter, pass the type of the varargs parameter to the matcher. For example, given a String... varargs parameter, use any(String[].class).

You had the right idea @timja when updating the code to use any(Class[].class), a small update was just missing a few lines above.

I reproduced the test failure locally, and can confirm that the change I'm proposing is fixing the tests.

Let me know if anything else is missing in that PR :smile:

timja commented 1 year ago

Sorry for dropping here unexpected

Why are you sorry 😂.

Thanks for figuring it out!