ARTEMIS-6370 AMQP large message delivery loop on short body

An AMQP large message whose stored body is smaller than the body size
recorded for it put the broker into an unrecoverable retry loop. The
streaming loop in AMQPLargeMessageWriter passed the result of
LargeBodyReader.readInto straight into ByteBuf.writerIndex, so the -1
that a sequential file read returns at end of file raised an
IndexOutOfBoundsException naming a writerIndex of -1.

That reached ProtonServerSenderContext.reportDeliveryError, which
removed the consumer and handed the reference back to the queue, so
the next consumer to attach failed the same way and the queue logged
AMQ222151 indefinitely while delivering nothing. A zero length read
had the same cause and spun the loop instead of raising anything.

The writer now checks the read before it is used and raises a
dedicated ActiveMQAMQPLargeMessageBodyTooSmallException, and the
sender sends that one condition to the dead letter address rather
than retrying a delivery that can never complete. It goes through
ServerConsumer reject so the reference leaves the consumer's
delivering list before the link is torn down, because the teardown
would otherwise return the message to the queue and the loop would
survive. The link is still closed, as a partial transfer may already
be on the wire and proton-j cannot abort one.

AMQPTunneledCoreLargeMessageWriter, which streams core large messages
over broker connections, had the same unguarded read. A negative read
there was added to the frame buffer writer index and to the position,
rewinding both until the writer index underflowed and raised the same
IndexOutOfBoundsException, while a zero length read spun silently. It
now raises the same error, and because it already reports through
reportDeliveryError it is dead lettered the same way.

AMQPSessionCallback.disconnect also dereferenced a protocol context
that the preceding consumer close clears on the queue executor, so
the teardown raised a NullPointerException of its own. It now checks
for null the way hasCredits in the same class already does.

Assisted-by: Claude Code (Opus 5) on behalf of Antonio Gagliardi
10 files changed
tree: 4295a55c44acaf3efabbfc9f713f1c92911b26c9
  1. .github/
  2. .settings/
  3. artemis-bom/
  4. artemis-boot/
  5. artemis-cdi-client/
  6. artemis-cli/
  7. artemis-commons/
  8. artemis-console/
  9. artemis-core-client/
  10. artemis-core-client-all/
  11. artemis-core-client-osgi/
  12. artemis-distribution/
  13. artemis-docker/
  14. artemis-dto/
  15. artemis-features/
  16. artemis-image/
  17. artemis-jakarta-cdi-client/
  18. artemis-jakarta-client/
  19. artemis-jakarta-client-all/
  20. artemis-jakarta-client-osgi/
  21. artemis-jakarta-ra/
  22. artemis-jakarta-server/
  23. artemis-jakarta-service-extensions/
  24. artemis-jdbc-store/
  25. artemis-jms-client/
  26. artemis-jms-client-all/
  27. artemis-jms-client-osgi/
  28. artemis-jms-server/
  29. artemis-journal/
  30. artemis-junit/
  31. artemis-lockmanager/
  32. artemis-log-annotation-processor/
  33. artemis-log4j/
  34. artemis-maven-plugin/
  35. artemis-pom/
  36. artemis-protocols/
  37. artemis-ra/
  38. artemis-selector/
  39. artemis-server/
  40. artemis-server-osgi/
  41. artemis-service-extensions/
  42. artemis-unit-test-support/
  43. artemis-web/
  44. artemis-website/
  45. docs/
  46. etc/
  47. relocations/
  48. scripts/
  49. tests/
  50. .asf.yaml
  51. .gitignore
  52. .project
  53. AGENTS.md
  54. artemis_doap.rdf
  55. LICENSE
  56. NOTICE
  57. pom.xml
  58. README.md
  59. RELEASING.adoc
  60. SECURITY.md
README.md

Welcome to Apache Artemis

Apache Artemis™ is multi-protocol message broker, supporting various industry standard protocols such as AMQP 1.0, MQTT 3.1.1, MQTT 5, and STOMP. This enables users to connect from across a broad range of languages and platforms, using clients written in Java, JavaScript, C, C++, Python, .Net, and more. Artemis offers the power and flexibility to support your messaging use-case.

Get Started

See the User Manual for an in-depth explanation of all aspects of broker configuration and behavior.

The Artemis Examples repository contains over 90 examples demonstrating many of the client and broker features.

Build from Source

See the Hacking Guide for details about modifying the code, building the project, running tests, etc.

Download a Release

Apache Artemis releases are available on the Apache Artemis website. We do not distribute releases via GitHub.

Report an Issue

See our website for details on how to report an bug, request a feature, etc.

Contact the Community

Get in touch with folks in the community using an official Apache mailing list or the Apache Slack instance. Details are available on the Apache Artemis website.

Contributing

Want to contribute? Details are available on the Apache Artemis website.