tabish121 commented on code in PR #4656:
URL: https://github.com/apache/activemq-artemis/pull/4656#discussion_r1373551849
##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java:
##########
@@ -980,6 +983,19 @@ class DefaultController implements SenderController {
@Override
public Consumer init(ProtonServerSenderContext senderContext) throws
Exception {
+ {
+ ProtonHandler handler;
+ Connection qpidConnection;
+ // Avoiding possible NPEs that could happen on mock tests
+ if (connection != null &&
+ (handler = connection.getHandler()) != null && (qpidConnection
= handler.getConnection()) != null) {
+ if (qpidConnection.getRemoteState() == EndpointState.CLOSED) {
+ logger.warn("AMQP Connection creating invalid consumer for
closed connection", connection);
+ throw new IllegalStateException("AMQP connection " +
connection.getRemoteAddress() + " creating invalid consumer for closed
connection");
+ }
+ }
+ }
+
Review Comment:
I'm not particularly fond of this "make mocking easier approach" as it
ignore what should be an invalid case of missing proton handler and connection.
If a test needs to mock this it should be able to supply mocks that answer
with mocked versions of these objects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]