Hotfix for DMF UPDATE_ATTRIBUTES message

This commit is contained in:
Stefan Behl
2018-07-31 12:01:14 +02:00
parent 13d8c6461c
commit 7ae941e290

View File

@@ -252,6 +252,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
private void updateAttributes(final Message message) {
final DmfAttributeUpdate attributeUpdate = convertMessage(message, DmfAttributeUpdate.class);
final String thingId = getStringHeaderKey(message, MessageHeaderKey.THING_ID, "ThingId is null");
// reject messages with invalid attributes
if (attributeUpdate.getAttributes().entrySet().stream()
.anyMatch(e -> !AmqpMessageHandlerService.isAttributeEntryValid(e))) {
throw new MessageConversionException(
@@ -262,9 +263,18 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
}
private static boolean isAttributeEntryValid(final Entry<String, String> e) {
if (e == null) return true;
return e.getKey() != null && e.getKey().length() <= 32 && (e.getValue() == null || (e.getValue() != null
&& e.getValue().length() <= 128));
if (e == null) {
return true;
}
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;
}
/**