Skip to content

Commit

Permalink
The AMQP client sender throws an NPE when processing an acknowledgeme…
Browse files Browse the repository at this point in the history
…nt as it assumes the delivery remote state is never null.

The sender is modified to handle the null case and report it as an unknown message state.
  • Loading branch information
vietj committed Feb 14, 2024
1 parent 3267f32 commit 027d669
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
15 changes: 15 additions & 0 deletions src/main/generated/io/vertx/amqp/AmqpClientOptionsConverter.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2018-2019 The original author or authors
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.amqp;

import io.vertx.core.json.JsonObject;
Expand Down
15 changes: 15 additions & 0 deletions src/main/generated/io/vertx/amqp/AmqpReceiverOptionsConverter.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2018-2019 The original author or authors
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.amqp;

import io.vertx.core.json.JsonObject;
Expand Down
15 changes: 15 additions & 0 deletions src/main/generated/io/vertx/amqp/AmqpSenderOptionsConverter.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2018-2019 The original author or authors
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.amqp;

import io.vertx.core.json.JsonObject;
Expand Down
17 changes: 9 additions & 8 deletions src/test/java/io/vertx/amqp/SenderUnknownAckStateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public void init() throws Exception {
AtomicReference<AmqpConnection> reference = new AtomicReference<>();
client = AmqpClient.create(vertx, new AmqpClientOptions()
.setHost("localhost")
.setPort(server.actualPort()))
.connect(connection -> {
.setPort(server.actualPort()));
client.connect()
.onComplete(connection -> {
reference.set(connection.result());
if (connection.failed()) {
connection.cause().printStackTrace();
Expand All @@ -64,14 +65,14 @@ public void tearDown() throws InterruptedException {

@Test(timeout = 10000)
public void test(TestContext context) throws Exception {
connection.createSender(address, context.asyncAssertSuccess(sender -> {
AmqpMessage msg = AmqpMessage.create().withBooleanAsBody(true).build();
sender
.write(msg)
.onComplete(context.asyncAssertFailure(expected -> {
connection.createSender(address)
.compose(sender -> {
AmqpMessage msg = AmqpMessage.create().withBooleanAsBody(true).build();
return sender
.write(msg);
}).onComplete(context.asyncAssertFailure(expected -> {
// Expected
}));
}));
}

private MockServer setupMockServer() throws Exception {
Expand Down

0 comments on commit 027d669

Please sign in to comment.