Fix timing issue in test for STOMP Server

https://build.spring.io/browse/INT-MASTER-733

The Netty tries to load `netty-transport-native-epoll` too long, more
then 10 seconds we expect in the `AbstractStompSessionManager`, therefore
 we end up having `StompConnectionFailedEvent` as a first event in the
queue channel for STOMP events.

* Increase connection wait timeout to `30 secs`, like it is in many other
places in Spring
* Provide some Java 8 style refactoring for the `AbstractStompSessionManager`
* Fix `StompServerIntegrationTests` to poll events from queue until
`StompSessionConnectedEvent` any way
* Upgrade to Gradle 4.0 and `spring-io-plugin-0.0.8`
* Bump `org.sonarqube` version to `2.5` - `2.1` isn't compatible with Gradle 4.0
This commit is contained in:
Artem Bilan
2017-06-23 15:41:37 -04:00
parent 0903df9676
commit a1c42f65d0
6 changed files with 42 additions and 42 deletions

View File

@@ -4,14 +4,14 @@ buildscript {
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE'
classpath 'io.spring.gradle:spring-io-plugin:0.0.7.RELEASE'
classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE'
classpath 'io.spring.gradle:docbook-reference-plugin:0.3.1'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
}
}
plugins {
id 'org.sonarqube' version '2.1'
id 'org.sonarqube' version '2.5'
}
description = 'Spring Integration'
@@ -193,7 +193,7 @@ subprojects { subproject ->
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/html"
html.destination file("${buildDir}/reports/jacoco/html")
}
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#Wed Apr 26 10:11:04 EDT 2017
#Fri Jun 23 15:29:14 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip

6
gradlew vendored
View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -198,39 +198,35 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
}
return;
}
final CountDownLatch latch = new CountDownLatch(1);
this.stompSessionListenableFuture.addCallback(new ListenableFutureCallback<StompSession>() {
final CountDownLatch connectLatch = new CountDownLatch(1);
this.stompSessionListenableFuture.addCallback(
stompSession -> {
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onSuccess");
}
AbstractStompSessionManager.this.connected = true;
AbstractStompSessionManager.this.connecting = false;
stompSession.setAutoReceipt(isAutoReceiptEnabled());
if (AbstractStompSessionManager.this.applicationEventPublisher != null) {
AbstractStompSessionManager.this.applicationEventPublisher.publishEvent(
new StompSessionConnectedEvent(this));
}
AbstractStompSessionManager.this.reconnectFuture = null;
connectLatch.countDown();
@Override
public void onFailure(Throwable e) {
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onFailure", e);
}
latch.countDown();
if (epoch == AbstractStompSessionManager.this.epoch.get()) {
scheduleReconnect(e);
}
}
},
e -> {
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onFailure", e);
}
connectLatch.countDown();
if (epoch == AbstractStompSessionManager.this.epoch.get()) {
scheduleReconnect(e);
}
});
@Override
public void onSuccess(StompSession stompSession) {
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onSuccess");
}
AbstractStompSessionManager.this.connected = true;
AbstractStompSessionManager.this.connecting = false;
stompSession.setAutoReceipt(isAutoReceiptEnabled());
if (AbstractStompSessionManager.this.applicationEventPublisher != null) {
AbstractStompSessionManager.this.applicationEventPublisher.publishEvent(
new StompSessionConnectedEvent(this));
}
AbstractStompSessionManager.this.reconnectFuture = null;
latch.countDown();
}
});
try {
if (!latch.await(10, TimeUnit.SECONDS)) {
if (!connectLatch.await(30, TimeUnit.SECONDS)) {
this.logger.error("No response to connection attempt");
if (epoch == this.epoch.get()) {
scheduleReconnect(null);
@@ -261,7 +257,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
if (this.stompClient.getTaskScheduler() != null) {
this.reconnectFuture = this.stompClient.getTaskScheduler()
.schedule((Runnable) () -> connect(), new Date(System.currentTimeMillis() + this.recoveryInterval));
.schedule(this::connect, new Date(System.currentTimeMillis() + this.recoveryInterval));
}
else {
this.logger.info("For automatic reconnection the 'stompClient' should be configured with a TaskScheduler.");

View File

@@ -118,9 +118,13 @@ public class StompServerIntegrationTests extends LogAdjustingTestSupport {
MessageChannel stompOutputChannel1 = context1.getBean("stompOutputChannel", MessageChannel.class);
MessageChannel stompOutputChannel2 = context2.getBean("stompOutputChannel", MessageChannel.class);
Message<?> eventMessage = stompEvents1.receive(10000);
Message<?> eventMessage;
do {
eventMessage = stompEvents1.receive(10000);
}
while (eventMessage != null && !(eventMessage.getPayload() instanceof StompSessionConnectedEvent));
assertNotNull(eventMessage);
assertThat(eventMessage.getPayload(), instanceOf(StompSessionConnectedEvent.class));
eventMessage = stompEvents1.receive(10000);
assertNotNull(eventMessage);