Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky ReactiveWebServerLoadBalancerInteropTest #5999

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.ServerResponse.ok;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -50,7 +52,7 @@

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import ch.qos.logback.core.AppenderBase;
import reactor.core.publisher.Mono;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
Expand Down Expand Up @@ -79,7 +81,7 @@ RouterFunction<ServerResponse> routerFunction() {
int port;

final Logger httpWebHandlerAdapterLogger = (Logger) LoggerFactory.getLogger(HttpWebHandlerAdapter.class);
final ListAppender<ILoggingEvent> logAppender = new ListAppender<>();
final ConcurrentListAppender<ILoggingEvent> logAppender = new ConcurrentListAppender<>();

@BeforeEach
public void attachAppender() {
Expand Down Expand Up @@ -148,4 +150,14 @@ private void assertNoErrorLogByHttpWebHandlerAdapter() {
.collect(Collectors.toList()))
.isEmpty();
}

private static final class ConcurrentListAppender<E> extends AppenderBase<E> {

List<E> list = new CopyOnWriteArrayList<>();

@Override
protected void append(E eventObject) {
list.add(eventObject);
}
}
}
Loading