Skip to content

Commit 7c872ed

Browse files
committed
8272124: Cgroup v1 initialization causes NullPointerException when cgroup path contains colon
Reviewed-by: shade Backport-of: 4d6593ce0243457e7431a5990957a8f880e0a3fb
1 parent cb0775f commit 7c872ed

File tree

1 file changed

+4
-1
lines changed
  • src/java.base/linux/classes/jdk/internal/platform/cgroupv1

1 file changed

+4
-1
lines changed

src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ private static Metrics initContainerSubSystems() {
116116
try (Stream<String> lines =
117117
readFilePrivileged(Paths.get("/proc/self/cgroup"))) {
118118

119-
lines.map(line -> line.split(":"))
119+
// The limit value of 3 is because /proc/self/cgroup contains three
120+
// colon-separated tokens per line. The last token, cgroup path, might
121+
// contain a ':'.
122+
lines.map(line -> line.split(":", 3))
120123
.filter(line -> (line.length >= 3))
121124
.forEach(line -> setSubSystemPath(metrics, line));
122125

0 commit comments

Comments
 (0)