RFR: 8290504: Close streams returned by ModuleReader::list

Mandy Chung mchung at openjdk.org
Wed Jul 20 20:21:03 UTC 2022


On Wed, 20 Jul 2022 08:14:39 GMT, Chris Hegarty <chegar at openjdk.org> wrote:

>> This commit ensures streams returned by ModuleReader::list are closed.
>
> test/jdk/java/lang/invoke/callerSensitive/CallerSensitiveAccess.java line 411:
> 
>> 409:         try (ModuleReader reader = mref.open();
>> 410:              Stream<String> stream = reader.list()) {
>> 411:             return stream
> 
> This change is causing the test to fail, in the `callerSensitiveMethods` DataProvider, because the data provider is expecting an open stream to be returned by `callerSensitiveMethods(Module)` - the stream is now closed.
> 
> There are a couple of ways to resolve this, but the most straightforward would be to revert this part of the change, and have the `callerSensitiveMethods` DataProvider close the returned stream. E.g.:
> 
> 
>   @DataProvider(name = "callerSensitiveMethods")
>   static Object[][] callerSensitiveMethods() {
>       try (var methodStream = callerSensitiveMethods(Object.class.getModule())) {
>           return methodStream
>                   .map(m -> new Object[]{m, shortDescription(m)})
>                   .toArray(Object[][]::new);
>       }
>   }

yes, this would solve it.

-------------

PR: https://git.openjdk.org/jdk/pull/9557


More information about the core-libs-dev mailing list