Skip to content

Commit

Permalink
8264526: javax/swing/text/html/parser/Parser/8078268/bug8078268.java …
Browse files Browse the repository at this point in the history
…timeout

Backport-of: da643cd
  • Loading branch information
DamonFool authored and John Jiang committed Nov 10, 2021
1 parent 1e99800 commit d8adeca
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, 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
Expand Down Expand Up @@ -39,6 +39,7 @@ public class bug8078268 {
static volatile Exception exception;

public static void main(String[] args) throws Exception {
long timeout = 10_000;
long s = System.currentTimeMillis();
SwingUtilities.invokeLater(new Runnable() {
@Override
Expand All @@ -53,14 +54,14 @@ public void run() {
}
}
});
while (!parsingDone && exception == null && System.currentTimeMillis() - s < 5_000) {
while (!parsingDone && exception == null && System.currentTimeMillis() - s < timeout) {
Thread.sleep(200);
}
final long took = System.currentTimeMillis() - s;
if (exception != null) {
throw exception;
}
if (took > 5_000) {
if (took > timeout) {
throw new RuntimeException("Parsing takes too long.");
}
}
Expand Down

1 comment on commit d8adeca

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.