Skip to content

Commit 3035cde

Browse files
committed
Merge branch '4.3.x-stable'
2 parents b05e917 + 11362df commit 3035cde

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/main/java/com/rabbitmq/client/impl/nio/SslEngineByteBufferInputStream.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ public int read() throws IOException {
6666
}
6767

6868
int bytesRead = NioHelper.read(channel, cipherIn);
69-
if (bytesRead > 0) {
70-
cipherIn.flip();
71-
} else {
69+
// see https://github.com/rabbitmq/rabbitmq-java-client/issues/307
70+
if (bytesRead <= 0) {
7271
bytesRead = NioHelper.retryRead(channel, cipherIn);
7372
if(bytesRead <= 0) {
7473
throw new IllegalStateException("Should be reading something from the network");
7574
}
7675
}
76+
cipherIn.flip();
77+
7778
plainIn.clear();
7879
result = sslEngine.unwrap(cipherIn, plainIn);
7980

src/test/java/com/rabbitmq/client/test/server/PersistenceGuarantees.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ protected NioParams nioParams() {
3434
NioParams nioParams = super.nioParams();
3535
// may need a higher enqueuing timeout on slow environments
3636
return nioParams
37-
.setWriteEnqueuingTimeoutInMs(nioParams.getWriteEnqueuingTimeoutInMs() * 2);
37+
.setWriteEnqueuingTimeoutInMs(nioParams.getWriteEnqueuingTimeoutInMs() * 3)
38+
.setWriteQueueCapacity(nioParams.getWriteQueueCapacity() * 2);
3839
}
3940

4041
protected void declareQueue() throws IOException {

src/test/java/com/rabbitmq/client/test/ssl/NioTlsUnverifiedConnection.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void openConnection()
4040
throws IOException, TimeoutException {
4141
try {
4242
connectionFactory.useSslProtocol();
43+
connectionFactory.useNio();
4344
} catch (Exception ex) {
4445
throw new IOException(ex.toString());
4546
}
@@ -55,15 +56,15 @@ public void openConnection()
5556
}
5657
}
5758
if(connection == null) {
58-
fail("Couldn't open TLS connection after 3 attemps");
59+
fail("Couldn't open TLS connection after 3 attempts");
5960
}
6061

6162
}
6263

6364
@Test
6465
public void connectionGetConsume() throws Exception {
6566
CountDownLatch latch = new CountDownLatch(1);
66-
connection = basicGetBasicConsume(connection, "tls.nio.queue", latch);
67+
connection = basicGetBasicConsume(connection, "tls.nio.queue", latch, 100 * 1000);
6768
boolean messagesReceived = latch.await(5, TimeUnit.SECONDS);
6869
assertTrue("Message has not been received", messagesReceived);
6970
}
@@ -94,20 +95,31 @@ public void configure(SSLEngine sslEngine) throws IOException {
9495
}
9596
}
9697

97-
private Connection basicGetBasicConsume(Connection connection, String queue, final CountDownLatch latch)
98+
@Test public void messageSize() throws Exception {
99+
int [] sizes = new int [] {100, 1000, 10 * 1000, 1 * 1000 * 1000, 5 * 1000 * 1000};
100+
for(int size : sizes) {
101+
CountDownLatch latch = new CountDownLatch(1);
102+
connection = basicGetBasicConsume(connection, "tls.nio.queue", latch, size);
103+
boolean messagesReceived = latch.await(5, TimeUnit.SECONDS);
104+
assertTrue("Message has not been received", messagesReceived);
105+
}
106+
}
107+
108+
private Connection basicGetBasicConsume(Connection connection, String queue, final CountDownLatch latch, int msgSize)
98109
throws IOException, TimeoutException {
99110
Channel channel = connection.createChannel();
100111
channel.queueDeclare(queue, false, false, false, null);
101112
channel.queuePurge(queue);
102113

103-
channel.basicPublish("", queue, null, new byte[100 * 1000]);
114+
channel.basicPublish("", queue, null, new byte[msgSize]);
104115

105116
channel.basicConsume(queue, false, new DefaultConsumer(channel) {
106117

107118
@Override
108119
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
109120
getChannel().basicAck(envelope.getDeliveryTag(), false);
110121
latch.countDown();
122+
getChannel().basicCancel(consumerTag);
111123
}
112124
});
113125

0 commit comments

Comments
 (0)