From 4b74741d179bf928f3fa8a77fc838c3c608f613a Mon Sep 17 00:00:00 2001
From: Goetz Lindenmaier <goetz@openjdk.org>
Date: Mon, 18 Nov 2024 13:46:53 +0000
Subject: [PATCH] 8284291: sun/security/krb5/auto/Renew.java fails
 intermittently on Windows 11

Backport-of: 05ae7ed1aac6fabc9c8820c12b6567fe93a3546f
---
 test/jdk/sun/security/krb5/auto/Renew.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/jdk/sun/security/krb5/auto/Renew.java b/test/jdk/sun/security/krb5/auto/Renew.java
index 9b3ac7db38b..30e5be285ab 100644
--- a/test/jdk/sun/security/krb5/auto/Renew.java
+++ b/test/jdk/sun/security/krb5/auto/Renew.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,10 @@ public class Renew {
         Date d1 = c.s().getPrivateCredentials(KerberosTicket.class).iterator().next().getAuthTime();
 
         // 6s is longer than half of 10s
-        Thread.sleep(6000);
+        Date expiring = new Date(d1.getTime() + 6000);
+        while (new Date().before(expiring)) {
+            Thread.sleep(500);
+        }
 
         // The second login uses the cache
         c = Context.fromJAAS("second");
-- 
GitLab