Mercurial > hg > openjdk > jdk8u > jdk
changeset 14456:6a07e2cb5bdb jdk8u302-b04
8206243: java -XshowSettings fails if memory.limit_in_bytes overflows LONG.max
Reviewed-by: sgehwolf
author | snazarki |
---|---|
date | Thu, 20 May 2021 16:26:15 +0300 |
parents | 821ac4be0e8f |
children | 521644855745 cb560b38d15a |
files | src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java Wed May 27 09:46:40 2020 -0700 +++ b/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java Thu May 20 16:26:15 2021 +0300 @@ -27,6 +27,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.math.BigInteger; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; @@ -156,7 +157,18 @@ public static long convertStringToLong(String strval) { if (strval == null) return 0L; - long retval = Long.parseLong(strval); + long retval = 0; + + try { + retval = Long.parseLong(strval); + } catch (NumberFormatException e) { + // For some properties (e.g. memory.limit_in_bytes) we may overflow the range of signed long. + // In this case, return Long.max + BigInteger b = new BigInteger(strval); + if (b.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { + return Long.MAX_VALUE; + } + } return retval; }