From 64dc4b18881081d196cdd2bf625603706e723033 Mon Sep 17 00:00:00 2001
From: Aleksey Shipilev <shade@openjdk.org>
Date: Fri, 23 Oct 2020 06:34:17 +0000
Subject: [PATCH] 8255225: compiler/aot tests fail on Windows with NPE during
 artifact resolution

Reviewed-by: erikj, clanger
---
 .../artifacts/ArtifactResolverException.java   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
index 17484d89d52..f3c2179191f 100644
--- a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
+++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
@@ -14,14 +14,22 @@ public class ArtifactResolverException extends Exception {
     }
 
     public String toString() {
-        return super.toString() + ": " + getRootCause().toString();
+        Throwable root = getRootCause();
+        if (root != null) {
+            return super.toString() + ": " + root.toString();
+        } else {
+            return super.toString();
+        }
     }
 
     public Throwable getRootCause() {
-        Throwable rootCause = getCause();
-        while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
-            rootCause = rootCause.getCause();
+        Throwable root = getCause();
+        if (root == null) {
+            return null;
         }
-        return rootCause;
+        while (root.getCause() != null && root.getCause() != root) {
+            root = root.getCause();
+        }
+        return root;
     }
 }