rtista commented on pull request #3365:
URL: https://github.com/apache/activemq-artemis/pull/3365#issuecomment-748685074
Hey @jbertram and @clebertsuconic! I partially agree with the desired
behavior you guys described and I don't mind implementing it and dealing with
the errors that may arise from it. However, most usages of the isfullyQualified
method are in if statements and it seems to me that adding the exception
throwing behavior will render this code (which calls isfullyQualified)
confusing.
I believe it would make more sense to throw an exception in methods such as
toFullyQualified, extractQueueName and extractAddressName than in
isFullyQualified since the latter is used by its callers to create logic
variations when a provided string is not in FQQN format. While some clients may
wish to throw an exception because they only support FQQN syntax, others may
wish to fallback to another behavior such as creating an ANYCAST queue with the
string provided.
I have tracked usages of CompositeAddress.isfullyQualified to the following
files:
```bash
[artista@astartes activemq-artemis]$ find . -type f -name "*.java" -exec
grep -l "CompositeAddress.isFullyQualified(" {} \;
./artemis-cli/src/test/java/org/apache/activemq/cli/test/CliProducerTest.java
./artemis-cli/src/test/java/org/apache/activemq/cli/test/MessageSerializerTest.java
./artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java
./artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
./artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
./artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
./artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
./artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
./artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
./artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
./artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
./artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
./artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java
```
The usages themselves are as follow where it is possible to see the high
amount of if statements:
```bash
[artista@astartes activemq-artemis]$ grep isFullyQualified -r | grep ".java:"
artemis-cli/src/test/java/org/apache/activemq/cli/test/CliProducerTest.java:
List<Message> received = consumeMessages(session, address,
TEST_MESSAGE_COUNT, CompositeAddress.isFullyQualified(address));
artemis-cli/src/test/java/org/apache/activemq/cli/test/MessageSerializerTest.java:
List<Message> received = consumeMessages(session, address,
TEST_MESSAGE_COUNT, CompositeAddress.isFullyQualified(address));
artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java:
if (CompositeAddress.isFullyQualified(address)) {
artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java:
if (CompositeAddress.isFullyQualified(name)) {
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java:
public static boolean isFullyQualified(String address) throws
ActiveMQInvalidQueueConfiguration {
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java:
public static boolean isFullyQualified(SimpleString address) throws
ActiveMQInvalidQueueConfiguration {
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java:
return address != null && isFullyQualified(address.toString());
artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java:
} else if (CompositeAddress.isFullyQualified(address)) { // it
could be a topic using FQQN
artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java:
if (!CompositeAddress.isFullyQualified(dest.getAddress())) {
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java:
if (CompositeAddress.isFullyQualified(source.getAddress())) {
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java:
if (CompositeAddress.isFullyQualified(physicalName)) {
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java:
if (CompositeAddress.isFullyQualified(queueName.toString())) {
artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java:
if ((CompositeAddress.isFullyQualified(destination) ||
effectiveAddressRoutingType == RoutingType.ANYCAST) &&
addressSettings.isAutoCreateQueues() &&
manager.getServer().locateQueue(simpleDestination) == null) {
artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java:
if (multicast && !CompositeAddress.isFullyQualified(destination)) {
artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java:
} else if (CompositeAddress.isFullyQualified(message.getAddress())) {
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java:
if (!newFQQN &&
CompositeAddress.isFullyQualified(address.toString())) {
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
securityCheck(CompositeAddress.extractAddressName(art.getName()),
CompositeAddress.isFullyQualified(art.getName()) ?
CompositeAddress.extractQueueName(art.getName()) : null, CheckType.SEND, this);
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
public void testIsFullyQualifiedInvalidFQQN() throws
ActiveMQInvalidQueueConfiguration {
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
CompositeAddress.isFullyQualified(failureScenario);
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
public void testIsFullyQualifiedNullQueue() throws
ActiveMQInvalidQueueConfiguration {
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
CompositeAddress.isFullyQualified(nullableQueueScenario);
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
public void testIsFullyQualifiedNullAddress() throws
ActiveMQInvalidQueueConfiguration {
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
CompositeAddress.isFullyQualified(nullableAddressScenario);
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
public void testIsFullyQualifiedSuccess() throws
ActiveMQInvalidQueueConfiguration {
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/CompositeAddressTest.java:
assertTrue("Valid FQQN was not validated.",
CompositeAddress.isFullyQualified(successScenario));
```
Let me know what you think about this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]