[ 
https://issues.apache.org/jira/browse/ARTEMIS-4982?focusedWorklogId=929871&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-929871
 ]

ASF GitHub Bot logged work on ARTEMIS-4982:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Aug/24 15:53
            Start Date: 12/Aug/24 15:53
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on code in PR #5138:
URL: https://github.com/apache/activemq-artemis/pull/5138#discussion_r1714032187


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFlowControlFailDispositionTests.java:
##########
@@ -105,4 +108,51 @@ public void testAddressFullDisposition() throws Exception {
          connection.close();
       }
    }
+
+   @TestTemplate
+   @Timeout(60)
+   public void testFailedLargeMessageSendWhenNoSpaceCleansUpLargeFile() throws 
Exception {
+      AmqpClient client = createAmqpClient(getBrokerAmqpConnectionURI());
+      AmqpConnection connection = client.connect();
+
+      int expectedRemainingLargeMessageFiles = 0;
+
+      try {
+         AmqpSession session = connection.createSession();
+         AmqpSender sender = session.createSender(getQueueName(), null, null, 
outcomes);
+         AmqpMessage message = createAmqpLargeMessageWithNoBody();
+         boolean rejected = false;
+
+         for (int i = 0; i < 1000; i++) {
+            try {
+               sender.send(message);
+               expectedRemainingLargeMessageFiles++;
+            } catch (IOException e) {
+               rejected = true;
+               assertTrue(e.getMessage().contains(expectedMessage),
+                          String.format("Unexpected message expected %s to 
contain %s", e.getMessage(), expectedMessage));
+               break;
+            }
+         }
+
+         assertTrue(rejected, "Expected messages to be refused by broker");
+      } finally {
+         connection.close();
+      }
+
+      validateNoFilesOnLargeDir(getLargeMessagesDir(), 
expectedRemainingLargeMessageFiles);
+   }
+
+   private AmqpMessage createAmqpLargeMessageWithNoBody() {
+      AmqpMessage message = new AmqpMessage();
+
+      byte[] payload = new byte[32 * 1024];

Review Comment:
   Would be good to tie this to the constant size so that it remains 'large' in 
the case anyone ever changed that config (e.g as you just did) without also 
updating this bit....test would still pass, but no longer cover what was 
intended.



##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSecurityTest.java:
##########
@@ -277,4 +286,79 @@ public void inspectOpenedResource(Sender sender) {
          connection.close();
       }
    }
+
+   @Test
+   @Timeout(30)
+   public void 
testAnonymousRelayLargeMessageSendFailsWithNotAuthorizedCleansUpLargeMessageFile()
 throws Exception {
+      CountDownLatch latch = new CountDownLatch(1);
+
+      AmqpClient client = createAmqpClient(guestPass, guestUser);
+      client.setValidator(new AmqpValidator() {
+
+         @Override
+         public void inspectDeliveryUpdate(Sender sender, Delivery delivery) {
+            DeliveryState state = delivery.getRemoteState();
+
+            if (!delivery.remotelySettled()) {
+               markAsInvalid("delivery is not remotely settled");
+            }
+
+            if (state instanceof Rejected) {
+               Rejected rejected = (Rejected) state;
+               if (rejected.getError() == null || 
rejected.getError().getCondition() == null) {
+                  markAsInvalid("Delivery should have been Rejected with an 
error condition");
+               } else {
+                  ErrorCondition error = rejected.getError();
+                  if 
(!error.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) {
+                     markAsInvalid("Should have been tagged with unauthorized 
access error");
+                  }
+               }
+            } else {
+               markAsInvalid("Delivery should have been Rejected");
+            }
+
+            latch.countDown();
+         }
+      });
+
+      final AmqpConnection connection = client.connect();
+
+      try {
+         final AmqpSession session = connection.createSession();
+         final AmqpSender sender = session.createAnonymousSender();
+         final AmqpMessage message = createAmqpLargeMessageWithNoBody();
+
+         message.setAddress(getQueueName());
+         message.setMessageId("msg" + 1);
+
+         try {
+            sender.send(message);
+            fail("Should not be able to send, message should be rejected");
+         } catch (Exception ex) {
+            ex.printStackTrace();
+         } finally {
+            sender.close();
+         }
+
+         assertTrue(latch.await(5, TimeUnit.SECONDS));
+         connection.getStateInspector().assertValid();
+      } finally {
+         connection.close();
+      }
+
+      validateNoFilesOnLargeDir();
+   }
+
+   private AmqpMessage createAmqpLargeMessageWithNoBody() {
+      AmqpMessage message = new AmqpMessage();
+
+      byte[] payload = new byte[64 * 1024];

Review Comment:
   Similarly here





Issue Time Tracking
-------------------

    Worklog Id:     (was: 929871)
    Time Spent: 20m  (was: 10m)

> AMQP Large message files not removed immediately on failed sends
> ----------------------------------------------------------------
>
>                 Key: ARTEMIS-4982
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4982
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 2.36.0
>            Reporter: Timothy A. Bish
>            Assignee: Timothy A. Bish
>            Priority: Major
>             Fix For: 2.37.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> When an incoming large message is rejected for any reason the large message 
> file is not cleaned up immediately as it should be.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to