Skip to content

Commit 7df998e

Browse files
committed
build: fix failing tests on CI
1 parent 8476770 commit 7df998e

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

jooby/src/main/java/io/jooby/Server.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ abstract class Base implements Server {
9393

9494
private final AtomicBoolean stopping = new AtomicBoolean();
9595

96+
/**
97+
* Clears custom connection lost listeners. Intended for internal testing use to prevent static
98+
* state leakage between tests. Internal usage only.
99+
*/
100+
static void clearState() {
101+
connectionLostListeners.clear();
102+
connectionLostListeners.add(Base.CONNECTION_LOST);
103+
addressInUseListeners.clear();
104+
addressInUseListeners.add(Base.ADDRESS_IN_USE);
105+
}
106+
96107
protected void fireStart(List<Jooby> applications, Executor defaultWorker) {
97108
for (Jooby app : applications) {
98109
app.setDefaultWorker(defaultWorker).start(this);

jooby/src/test/java/io/jooby/DefaultContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void sendErrorCustomHandlerException() {
865865
doThrow(new RuntimeException("Handler crashed")).when(errorHandler).apply(any(), any(), any());
866866

867867
ctx.sendError(cause);
868-
verify(log).error(anyString(), anyString(), any(RuntimeException.class));
868+
verify(log).error(anyString(), any(RuntimeException.class));
869869
}
870870

871871
@Test

jooby/src/test/java/io/jooby/Issue2369.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
import static org.junit.jupiter.api.Assertions.assertFalse;
99
import static org.junit.jupiter.api.Assertions.assertTrue;
1010

11+
import org.junit.jupiter.api.AfterEach;
12+
import org.junit.jupiter.api.BeforeEach;
1113
import org.junit.jupiter.api.Test;
1214

1315
public class Issue2369 {
1416

17+
@BeforeEach
18+
@AfterEach
19+
public void cleanState() {
20+
Server.Base.clearState();
21+
}
22+
1523
@Test
1624
public void shouldCustomizeServerLostException() {
1725
Throwable cause = new IllegalArgumentException();

0 commit comments

Comments
 (0)