Skip to content

Commit 0017b36

Browse files
committed
Change test expectation
Garbage in the SASL frame can also trigger a timeout because the broker closes the connection before the client can throw the SASL error.
1 parent 2a4ef80 commit 0017b36

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/rabbitmq/stream/impl/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ public void run() {
28772877
try {
28782878
this.message.release();
28792879
} catch (Exception e) {
2880-
e.printStackTrace();
2880+
LOGGER.info("Error while releasing buffer after connection closing: {}", e.getMessage());
28812881
}
28822882
} else {
28832883
this.frameHandler.handle(this.client, this.frameSize, this.ctx, this.message);

src/test/java/com/rabbitmq/stream/impl/AuthenticationTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.rabbitmq.stream.StreamException;
2424
import com.rabbitmq.stream.sasl.*;
2525
import java.nio.charset.StandardCharsets;
26+
import java.time.Duration;
2627
import java.util.UUID;
2728
import org.junit.jupiter.api.Test;
2829
import org.junit.jupiter.api.extension.ExtendWith;
@@ -87,6 +88,7 @@ void authenticateShouldFailWhenSendingGarbageToSaslChallenge() {
8788
try {
8889
cf.get(
8990
new Client.ClientParameters()
91+
.rpcTimeout(Duration.ofSeconds(1))
9092
.saslConfiguration(
9193
mechanisms ->
9294
new SaslMechanism() {
@@ -102,7 +104,10 @@ public byte[] handleChallenge(
102104
}
103105
}));
104106
} catch (StreamException e) {
105-
assertThat(e.getMessage()).contains(String.valueOf(Constants.RESPONSE_CODE_SASL_ERROR));
107+
// there can be a timeout because the connection gets closed before returning the error
108+
assertThat(e.getMessage())
109+
.containsAnyOf(
110+
String.valueOf(Constants.RESPONSE_CODE_SASL_ERROR), "Could not get response in");
106111
}
107112
}
108113

0 commit comments

Comments
 (0)