rabbitmq-java-client icon indicating copy to clipboard operation
rabbitmq-java-client copied to clipboard

AMQContentHeader toString uses dashes instead of underscores for property names

Open ddewaele opened this issue 9 years ago • 2 comments

The com.rabbitmq.client.impl.AMQContentHeader has the following toString implementation

    @Override public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("#contentHeader<").append(getClassName()).append(">");
        this.appendPropertyDebugStringTo(sb);
        return sb.toString();
    }

It generates strings like this

#contentHeader<basic>(content-type=application/json, content-encoding=UTF-8, headers={topic=DOWNLOAD_AND_INSTALL, content-type=application/json, type=EVENT, tenant=DEFAULT, __TypeId__=org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest, thingId=new_device}, delivery-mode=2, priority=0, correlation-id=null, reply-to=null, expiration=null, message-id=null, timestamp=null, type=null, user-id=null, app-id=null, cluster-id=null)

This could make believe that content-type, content-encoding,..... are "valid" AMQP properties, while in fact RabbitMQ states :

Invalid properties will be ignored. Valid properties are:

content_type
content_encoding
priority
correlation_id
reply_to
expiration
message_id
timestamp
type
user_id
app_id
cluster_id

Notice the difference between the dash (-) and the ('_underscore')

To avoid confusion, the java client should print the "official" property names using underscores.

ddewaele avatar May 29 '16 12:05 ddewaele

Property naming is in part language specific. I'm OK with outputting them the way they are expected to be provided somewhere else (I'm guessing in the management UI?) but underscores in names are expected in some languages and not expected in others.

michaelklishin avatar May 29 '16 15:05 michaelklishin

I understand. but to toString implies that these are the property key/value pairs that are set on the AMQContentHeader (part of the message).

By using dashes it only adds to the confusion (I think the dash notation isn't used anywhere else).

This toString output is also not really java language specific. It should denote the content of the AMQContentHeader IMHO.

ddewaele avatar May 29 '16 18:05 ddewaele