Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amqp Message Update - API Change #17464

Merged
merged 25 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.core.serializer.json.gson.JsonNodeUtils.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.core.serializer.json.jackson.JsonNodeUtils.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.core.experimental.util.BinaryData.java"/>
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ThrowFromClientLoggerCheck|GoodLoggingCheck)" files="com.azure.core.amqp.models.AmqpMessageBody.java"/>

<!-- Azure Core Test -->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files=".*[/\\]core[/\\]test[/\\].*\.java"/>
Expand Down
81 changes: 81 additions & 0 deletions eng/code-quality-reports/src/main/resources/revapi/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,87 @@
"code": "java.annotation.added",
"new": "class com.azure.storage.blob.models.PageList",
"justification": "Annotation required to resolve deserialization bug."
},{
"code": "java.method.returnTypeChanged",
"old": "method com.azure.core.util.IterableStream<byte[]> com.azure.core.amqp.models.AmqpDataBody::getData()",
"new": "method java.util.List<byte[]> com.azure.core.amqp.models.AmqpDataBody::getData()",
"justification": "Updated "
},
{
"code": "java.class.removed",
"old": "class com.azure.core.amqp.models.AmqpDataBody",
"justification": "Renamed as AmqpMessageBody."
},
{
"code": "java.class.kindChanged",
"old": "interface com.azure.core.amqp.models.AmqpMessageBody",
"new": "class com.azure.core.amqp.models.AmqpMessageBody",
"justification": "AmqpMessageBody is class representing all the new AMQP data types."
},
{
"code": "java.class.nowFinal",
"old": "interface com.azure.core.amqp.models.AmqpMessageBody",
"new": "class com.azure.core.amqp.models.AmqpMessageBody",
"justification": "Made it final."
},
{
"code": "java.class.removed",
"old": "enum com.azure.core.amqp.models.AmqpBodyType",
"justification": "Because It is renamed to AmqpMessageBodyType"
},
{
"code": "java.method.returnTypeChanged",
"old": "method com.azure.core.amqp.models.AmqpBodyType com.azure.core.amqp.models.AmqpMessageBody::getBodyType()",
"new": "method com.azure.core.amqp.models.AmqpMessageBodyType com.azure.core.amqp.models.AmqpMessageBody::getBodyType()",
"justification": "Renamed to matach AmqpMessage prefix."
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
},
{
"code": "java.method.returnTypeChanged",
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getCorrelationId()",
"new": "method com.azure.core.amqp.models.AmqpMessageId com.azure.core.amqp.models.AmqpMessageProperties::getCorrelationId()",
"justification": "New return type AmqpMessageId."
},
{
"code": "java.method.returnTypeChanged",
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getMessageId()",
"new": "method com.azure.core.amqp.models.AmqpMessageId com.azure.core.amqp.models.AmqpMessageProperties::getMessageId()",
"justification": "New return type."
},
{
"code": "java.method.returnTypeChanged",
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getReplyTo()",
"new": "method com.azure.core.amqp.models.AmqpAddress com.azure.core.amqp.models.AmqpMessageProperties::getReplyTo()",
"justification": "New return type."
},
{
"code": "java.method.returnTypeChanged",
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getTo()",
"new": "method com.azure.core.amqp.models.AmqpAddress com.azure.core.amqp.models.AmqpMessageProperties::getTo()",
"justification": "New return type."
},
{
"code": "java.method.parameterTypeChanged",
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setCorrelationId(===java.lang.String===)",
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setCorrelationId(===com.azure.core.amqp.models.AmqpMessageId===)",
"justification": "Introduced new type AmqpMessageId."
},
{
"code": "java.method.parameterTypeChanged",
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setMessageId(===java.lang.String===)",
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setMessageId(===com.azure.core.amqp.models.AmqpMessageId===)",
"justification":"Introduced new type AmqpMessageId."
},
{
"code": "java.method.parameterTypeChanged",
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setReplyTo(===java.lang.String===)",
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setReplyTo(===com.azure.core.amqp.models.AmqpAddress===)",
"justification": "Introduced new type AmqpAddress."
},
{
"code": "java.method.parameterTypeChanged",
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setTo(===java.lang.String===)",
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setTo(===com.azure.core.amqp.models.AmqpAddress===)",
"justification": "Introduced new type AmqpAddress."
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.core.amqp.models;

import java.util.Objects;

/**
* This represents amqp address information. This will be used in populating information like 'To', 'ReplyTo' etc.
*
* @see <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string">
* Address type Format.</a>
JonathanGiles marked this conversation as resolved.
Show resolved Hide resolved
*/
public final class AmqpAddress {

private final String address;

/**
* Creates the {@link AmqpAddress} with given {@code address}.
*
* @param address to use.
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
*/
public AmqpAddress(String address) {
this.address = Objects.requireNonNull(address, "'address' cannot be null.");
}

@Override
public int hashCode() {
return address.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object other) {
if (other == null) {
return false;
}

if (this.getClass() != other.getClass()) {
return false;
}

if (this == other) {
return true;
}

if (!address.equals(other.toString())) {
return false;
}

return true;
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Gets string representation of the address.
*
* @return string representation of the address.
*/
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
@Override
public String toString() {
return this.address;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package com.azure.core.amqp.models;

import com.azure.core.util.logging.ClientLogger;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand All @@ -14,6 +16,7 @@
* Amqp Message Format.</a>
*/
public final class AmqpAnnotatedMessage {
private final ClientLogger logger = new ClientLogger(AmqpAnnotatedMessage.class);
private final AmqpMessageBody amqpMessageBody;
private final Map<String, Object> applicationProperties;
private final Map<String, Object> deliveryAnnotations;
Expand Down Expand Up @@ -46,10 +49,27 @@ public AmqpAnnotatedMessage(AmqpMessageBody body) {
* @param message used to create another instance of {@link AmqpAnnotatedMessage}.
*
* @throws NullPointerException if {@code message} or {@link AmqpAnnotatedMessage#getBody() body} is null.
* @throws UnsupportedOperationException if {@link AmqpMessageBodyType} is {@link AmqpMessageBodyType#SEQUENCE} or
* {@link AmqpMessageBodyType#VALUE}.
* @throws IllegalStateException for invalid {@link AmqpMessageBodyType}.
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
*/
public AmqpAnnotatedMessage(AmqpAnnotatedMessage message) {
Objects.requireNonNull(message, "'message' cannot be null.");
amqpMessageBody = Objects.requireNonNull(message.getBody(), "'message.body' cannot be null.");

AmqpMessageBodyType bodyType = message.getBody().getBodyType();
switch (bodyType) {
case DATA:
amqpMessageBody = AmqpMessageBody.fromData(message.getBody().getFirstData());
break;
case SEQUENCE:
case VALUE:
throw logger.logExceptionAsError(new UnsupportedOperationException("Body type not supported yet "
+ bodyType.toString()));
default:
throw logger.logExceptionAsError(new IllegalStateException("Body type not valid "
+ bodyType.toString()));
}
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved

applicationProperties = new HashMap<>(message.getApplicationProperties());
deliveryAnnotations = new HashMap<>(message.getDeliveryAnnotations());
messageAnnotations = new HashMap<>(message.getMessageAnnotations());
Expand All @@ -58,6 +78,7 @@ public AmqpAnnotatedMessage(AmqpAnnotatedMessage message) {
properties = new AmqpMessageProperties(message.getProperties());
}


/**
* Gets the {@link Map} of application properties.
*
Expand All @@ -69,6 +90,10 @@ public Map<String, Object> getApplicationProperties() {

/**
* Gets the {@link AmqpMessageBody} of an amqp message.
* <b>Client should test for {@link AmqpMessageBodyType} before calling corresponding get method on
* {@link AmqpMessageBody}</b>
* <p><strong>How to check for {@link AmqpMessageBodyType}</strong></p>
* {@codesnippet com.azure.core.amqp.models.AmqpBodyType.checkBodyType}
*
* @return the {@link AmqpMessageBody} object.
*/
Expand Down

This file was deleted.

This file was deleted.

Loading