Hotfix for DMF UPDATE_ATTRIBUTES message
This commit is contained in:
@@ -252,6 +252,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
private void updateAttributes(final Message message) {
|
private void updateAttributes(final Message message) {
|
||||||
final DmfAttributeUpdate attributeUpdate = convertMessage(message, DmfAttributeUpdate.class);
|
final DmfAttributeUpdate attributeUpdate = convertMessage(message, DmfAttributeUpdate.class);
|
||||||
final String thingId = getStringHeaderKey(message, MessageHeaderKey.THING_ID, "ThingId is null");
|
final String thingId = getStringHeaderKey(message, MessageHeaderKey.THING_ID, "ThingId is null");
|
||||||
|
// reject messages with invalid attributes
|
||||||
if (attributeUpdate.getAttributes().entrySet().stream()
|
if (attributeUpdate.getAttributes().entrySet().stream()
|
||||||
.anyMatch(e -> !AmqpMessageHandlerService.isAttributeEntryValid(e))) {
|
.anyMatch(e -> !AmqpMessageHandlerService.isAttributeEntryValid(e))) {
|
||||||
throw new MessageConversionException(
|
throw new MessageConversionException(
|
||||||
@@ -262,9 +263,18 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAttributeEntryValid(final Entry<String, String> e) {
|
private static boolean isAttributeEntryValid(final Entry<String, String> e) {
|
||||||
if (e == null) return true;
|
if (e == null) {
|
||||||
return e.getKey() != null && e.getKey().length() <= 32 && (e.getValue() == null || (e.getValue() != null
|
return true;
|
||||||
&& e.getValue().length() <= 128));
|
}
|
||||||
|
return isAttributeKeyValid(e.getKey()) && isAttributeValueValid(e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAttributeKeyValid(final String key) {
|
||||||
|
return key != null && key.length() <= 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAttributeValueValid(final String value) {
|
||||||
|
return value == null || value.length() <= 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user