RFR: 8255908: ExceptionInInitializerError due to UncheckedIOException while initializing cgroupv1 subsystem

Poonam Bajaj poonam at openjdk.java.net
Thu Nov 19 15:04:05 UTC 2020


On Thu, 19 Nov 2020 14:36:27 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Hi,
>> 
>> Please review this simple change that catches UncheckedIOException that can occur if /proc/self/cgroup or /proc/self/mountinfo files don't exist on the system, or if there is an interrupt while these are being read.
>> 
>> Testing: Tier1, Tier2 and Tier3.
>> 
>> Thanks,
>> Poonam
>
> src/java.base/linux/classes/jdk/internal/platform/cgroupv1/CgroupV1Subsystem.java line 79:
> 
>> 77:                  .forEach(entry -> createSubSystemController(subsystem, entry));
>> 78: 
>> 79:         } catch (UncheckedIOException e) {
> 
> I am confused. `CgroupUtil.readFilePrivileged` unwraps `UncheckedIOException`, why this catch clause is needed? Is this because the cause might be `UncheckedIOException` itself? Might be easier to rewrap `UncheckedIOException` to just `IOException` in `CgroupUtil`.

It is there to catch the UncheckedIOException that could get thrown while processing each line and entry. Example of this exception encountered with JDK 8u.

Caused by: java.io.UncheckedIOException:
java.nio.channels.ClosedByInterruptException
at java.io.BufferedReader$1.hasNext(BufferedReader.java:574)
at java.util.Iterator.forEachRemaining(Iterator.java:115)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at jdk.internal.platform.cgroupv1.Metrics.initContainerSubSystems(Metrics.java:81)
at jdk.internal.platform.cgroupv1.Metrics.<clinit>(Metrics.java:51)... 41 more

Caused by: java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:202)
at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:164)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
at java.io.BufferedReader$1.hasNext(BufferedReader.java:571)

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

PR: https://git.openjdk.java.net/jdk/pull/1303


More information about the core-libs-dev mailing list