From 75c7377e4762b3204f50bfdb66b1d8f6c7a2d1b4 Mon Sep 17 00:00:00 2001 From: Alex Herbert Date: Fri, 20 Aug 2021 21:19:23 +0100 Subject: [PATCH] Only restore interrupted state if necessary --- .../math4/examples/sofm/tsp/TravellingSalesmanSolver.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java index 478310dfb..d6eb45bfb 100644 --- a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java +++ b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java @@ -124,8 +124,10 @@ public final class TravellingSalesmanSolver { f.get(); } } catch (InterruptedException | ExecutionException e) { - // Restore interrupted state... - Thread.currentThread().interrupt(); + if (e instanceof InterruptedException) { + // Restore interrupted state... + Thread.currentThread().interrupt(); + } throw new RuntimeException(e); } // Terminate all threads.