Skip to content

RMQObjectFactory does not allow creating some variants of RMQDestination #129

@l-k-test

Description

@l-k-test

Constructor RMQDestination(String destName, String amqpExchangeName, String amqpRoutingKey, String amqpQueueName) says the following:

amqpExchangeName and amqpRoutingKey must both be null if either is null, and amqpQueueName may be null, but atleast one of these three parameters must be non-null.

Basically it allows some parameters be null.

At the same time RMQObjectFactory has the following code:

    public Object createDestination(Reference ref, Hashtable<?, ?> environment, Name name, boolean topic) throws NamingException {
        this.logger.trace("Creating destination ref '{}', name '{}' (topic={}).", ref, name, topic);
        String dname = getStringProperty(ref, environment, "destinationName", false, null);
        boolean amqp = getBooleanProperty(ref, environment, "amqp", true, false);
        if (amqp) {
            String amqpExchangeName = getStringProperty(ref, environment, "amqpExchangeName", false, null);
            String amqpRoutingKey = getStringProperty(ref, environment,"amqpRoutingKey", false, null);
            String amqpQueueName = getStringProperty(ref, environment, "amqpQueueName", false, null);
            return new RMQDestination(dname, amqpExchangeName, amqpRoutingKey, amqpQueueName);
        } else {
            return new RMQDestination(dname, !topic, false);
        }
    }

amqpExchangeName, amqpRoutingKey, and amqpQueueName all retrieved by getStringProperty() with parameter mayBeNull set to false.

As a result an instance of RMQDestination with both amqpExchangeName and amqpRoutingKey set to null can be created with RMQDestination constructor but not via RMQObjectFactory.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions