RFR: 8290504: Close streams returned by ModuleReader::list [v2]

Ryan Ernst duke at openjdk.org
Wed Jul 20 20:58:58 UTC 2022


On Wed, 20 Jul 2022 20:17:27 GMT, Mandy Chung <mchung at openjdk.org> wrote:

>> 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.

Done in [4a94c64](https://github.com/openjdk/jdk/pull/9557/commits/4a94c645fe1e37abc694f81fd8e401c5dc367d68)

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

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


More information about the core-libs-dev mailing list