8255908: ExceptionInInitializerError due to UncheckedIOException while initializing cgroupv1 subsystem

Reviewed-by: shade, sgehwolf, bobv
This commit is contained in:
Poonam Bajaj 2020-11-20 18:40:01 +00:00
parent 5ad1e22866
commit 8d9cf48e81
4 changed files with 23 additions and 2 deletions

View File

@ -26,6 +26,7 @@
package jdk.internal.platform;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.math.BigInteger;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -169,8 +170,9 @@ public interface CgroupSubsystemController {
.findFirst();
return result.isPresent() ? Long.parseLong(result.get()) : defaultRetval;
}
catch (IOException e) {
} catch (UncheckedIOException e) {
return defaultRetval;
} catch (IOException e) {
return defaultRetval;
}
}

View File

@ -27,6 +27,7 @@ package jdk.internal.platform;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -45,6 +46,8 @@ public final class CgroupUtil {
} catch (PrivilegedActionException e) {
unwrapIOExceptionAndRethrow(e);
throw new InternalError(e.getCause());
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
@ -68,6 +71,8 @@ public final class CgroupUtil {
} catch (PrivilegedActionException e) {
unwrapIOExceptionAndRethrow(e);
throw new InternalError(e.getCause());
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
@ -78,6 +83,8 @@ public final class CgroupUtil {
} catch (PrivilegedActionException e) {
unwrapIOExceptionAndRethrow(e);
throw new InternalError(e.getCause());
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
}

View File

@ -26,6 +26,7 @@
package jdk.internal.platform.cgroupv1;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
@ -75,6 +76,8 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
.map(line -> line.split(" "))
.forEach(entry -> createSubSystemController(subsystem, entry));
} catch (UncheckedIOException e) {
return null;
} catch (IOException e) {
return null;
}
@ -109,6 +112,8 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
.filter(line -> (line.length >= 3))
.forEach(line -> setSubSystemControllerPath(subsystem, line));
} catch (UncheckedIOException e) {
return null;
} catch (IOException e) {
return null;
}

View File

@ -26,6 +26,7 @@
package jdk.internal.platform.cgroupv2;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -69,6 +70,8 @@ public class CgroupV2Subsystem implements CgroupSubsystem {
.collect(Collectors.joining());
String[] tokens = l.split(" ");
mountPath = tokens[4];
} catch (UncheckedIOException e) {
return null;
} catch (IOException e) {
return null;
}
@ -87,6 +90,8 @@ public class CgroupV2Subsystem implements CgroupSubsystem {
cgroupPath = tokens[2];
break;
}
} catch (UncheckedIOException e) {
return null;
} catch (IOException e) {
return null;
}
@ -329,6 +334,8 @@ public class CgroupV2Subsystem implements CgroupSubsystem {
return CgroupUtil.readFilePrivileged(Paths.get(unified.path(), "io.stat"))
.map(mapFunc)
.collect(Collectors.summingLong(e -> e));
} catch (UncheckedIOException e) {
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
} catch (IOException e) {
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
}