From 42bda55e1d0c7d6afa9d4ad03253329f329b5d59 Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Wed, 12 Jul 2023 10:57:49 +0200 Subject: [PATCH] Make sure that ReverseProxy is started at the end of start method. This should fix some instability in test using that class. --- .../integration/tests/util/ReverseProxy.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/ReverseProxy.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/ReverseProxy.java index ba6e9bea46..064b5173e9 100644 --- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/ReverseProxy.java +++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/ReverseProxy.java @@ -121,6 +121,18 @@ public void start() { logAndRaiseException("Unexpected IO Exception when running proxy", e); } }); + + // Wait until proxy is really running + for (int i = 0; i < 10 && running; i++) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + LOGGER.debug("Start was interrupted", e); + } + } + if (!running) { + LOGGER.error("Unable to start ReverseProxy"); + } } private void handleClientPackets() throws IOException { @@ -234,7 +246,7 @@ public void changeServerSideProxyAddress() { try { Thread.sleep(100); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.debug("Change Server Side Proxy Address was interrupted", e); } } }