Skip to content

Commit b12540d

Browse files
authored
GH-3598: Fix delay in waitStopListening()
Fixes #3598 `TestingUtilities.waitStopListening(serverConnectionFactory, delayArg)` actually waits for `delayArg * 2` milliseconds which is inconsistent with the JavaDocs. * Fix `TestingUtilities.waitStopListening()` to sleep for `100` between attempts and compare `n` attempts against `delay / 100`
1 parent 0a7ea59 commit b12540d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -122,13 +122,13 @@ public static void waitStopListening(AbstractServerConnectionFactory serverConne
122122
int n = 0;
123123
while (serverConnectionFactory.isListening()) {
124124
try {
125-
Thread.sleep(delay);
125+
Thread.sleep(100); // NOSONAR magic number
126126
}
127127
catch (InterruptedException e) {
128128
Thread.currentThread().interrupt();
129129
throw new IllegalStateException(e);
130130
}
131-
if (n++ > 200) { // NOSONAR magic number
131+
if (n++ > delay) {
132132
throw new IllegalStateException("Server didn't stop listening.");
133133
}
134134
}

0 commit comments

Comments
 (0)