changeset 14918:b3a2a55962b2

8255908: ExceptionInInitializerError due to UncheckedIOException while initializing cgroupv1 subsystem Reviewed-by: clanger, aph
author sgehwolf
date Fri, 20 Nov 2020 18:40:01 +0000
parents b7be27e5e8ea
children 90cbca4d2c6b
files src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java	Wed Jan 06 16:39:08 2021 +0000
+++ b/src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java	Fri Nov 20 18:40:01 2020 +0000
@@ -27,6 +27,7 @@
 package jdk.internal.platform.cgroupv1;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -85,6 +86,8 @@
 
         } catch (IOException e) {
             return null;
+        } catch (UncheckedIOException e) {
+            return null;
         }
 
         /**
@@ -119,6 +122,8 @@
 
         } catch (IOException e) {
             return null;
+        } catch (UncheckedIOException e) {
+            return null;
         }
 
         // Return Metrics object if we found any subsystems.
@@ -136,6 +141,8 @@
         } catch (PrivilegedActionException e) {
             unwrapIOExceptionAndRethrow(e);
             throw new InternalError(e.getCause());
+        } catch (UncheckedIOException e) {
+            throw e.getCause();
         }
     }
 
--- a/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java	Wed Jan 06 16:39:08 2021 +0000
+++ b/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java	Fri Nov 20 18:40:01 2020 +0000
@@ -27,6 +27,7 @@
 
 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;
@@ -110,6 +111,8 @@
         } catch (PrivilegedActionException e) {
             Metrics.unwrapIOExceptionAndRethrow(e);
             throw new InternalError(e.getCause());
+        } catch (UncheckedIOException e) {
+            throw e.getCause();
         }
     }
 
@@ -140,6 +143,8 @@
         } catch (PrivilegedActionException e) {
             Metrics.unwrapIOExceptionAndRethrow(e);
             throw new InternalError(e.getCause());
+        } catch (UncheckedIOException e) {
+            throw e.getCause();
         }
     }
 
@@ -193,8 +198,9 @@
                                            .findFirst();
 
             return result.isPresent() ? Long.parseLong(result.get()) : 0L;
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
+            return 0L;
+        } catch (UncheckedIOException e) {
             return 0L;
         }
     }