Skip to content

Commit 586344d

Browse files
committed
remove debug deadlines
1 parent 40dfb1b commit 586344d

1 file changed

Lines changed: 10 additions & 32 deletions

File tree

loader/core/src/main/java/pl/skidam/automodpack_loader_core/client/ModpackUtils.java

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -725,21 +725,10 @@ public static Function<X509Certificate, Boolean> userValidationCallback(InetSock
725725
private static Boolean askUserAboutCertificate(InetSocketAddress address, String fingerprint) {
726726
LOGGER.info("Asking user for {}", address.getHostString());
727727

728-
Object parent = null;
729-
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30);
730-
while (parent == null) {
731-
parent = new ScreenManager().getScreen().orElse(null);
732-
if (parent == null) {
733-
if (System.nanoTime() > deadline) {
734-
LOGGER.warn("No screen available, cannot ask user");
735-
return false;
736-
}
737-
try {
738-
Thread.sleep(100);
739-
} catch (InterruptedException e) {
740-
return false;
741-
}
742-
}
728+
var parent = new ScreenManager().getScreen().orElse(null);
729+
if (parent == null) {
730+
LOGGER.warn("No screen available, cannot ask user");
731+
return false;
743732
}
744733

745734
CountDownLatch latch = new CountDownLatch(1);
@@ -855,22 +844,11 @@ private static CompletableFuture<Boolean> askUserAboutCertificateAsync(InetSocke
855844
LOGGER.info("Asking user for {}", address.getHostString());
856845

857846
return CompletableFuture.supplyAsync(() -> {
858-
Object screen = null;
859-
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30);
860-
while (screen == null) {
861-
screen = new ScreenManager().getScreen().orElse(null);
862-
if (screen == null) {
863-
if (System.nanoTime() > deadline) {
864-
LOGGER.warn("No screen available, cannot ask user");
865-
return false;
866-
}
867-
try {
868-
Thread.sleep(100);
869-
} catch (InterruptedException e) {
870-
return false;
871-
}
872-
}
873-
}
847+
var parent = new ScreenManager().getScreen().orElse(null);
848+
if (parent == null) {
849+
LOGGER.warn("No screen available, cannot ask user");
850+
return false;
851+
}
874852

875853
CompletableFuture<Boolean> future = new CompletableFuture<>();
876854
Runnable trustAction = () -> {
@@ -879,7 +857,7 @@ private static CompletableFuture<Boolean> askUserAboutCertificateAsync(InetSocke
879857
future.complete(true);
880858
};
881859
Runnable cancelAction = () -> future.complete(false);
882-
new ScreenManager().validation(screen, fingerprint, trustAction, cancelAction);
860+
new ScreenManager().validation(parent, fingerprint, trustAction, cancelAction);
883861

884862
try {
885863
return future.get(120, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)