Browse Source

fixed "No value present"

pull/6055/head
YevhenBondarenko 5 years ago
parent
commit
a0b4f7c38e
  1. 9
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClient.java

9
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClient.java

@ -423,15 +423,18 @@ public class LwM2mClient implements Serializable {
private ContentFormat calculateDefaultContentFormat(Registration registration) { private ContentFormat calculateDefaultContentFormat(Registration registration) {
if (registration == null) { if (registration == null) {
return ContentFormat.DEFAULT; return ContentFormat.DEFAULT;
} else{ } else {
return TbLwM2mVersion.fromVersion(registration.getLwM2mVersion()).getContentFormat(); return TbLwM2mVersion.fromVersion(registration.getLwM2mVersion()).getContentFormat();
} }
} }
static private Set<ContentFormat> clientSupportContentFormat(Registration registration) { private static Set<ContentFormat> clientSupportContentFormat(Registration registration) {
Set<ContentFormat> contentFormats = new HashSet<>(); Set<ContentFormat> contentFormats = new HashSet<>();
contentFormats.add(ContentFormat.DEFAULT); contentFormats.add(ContentFormat.DEFAULT);
LinkParamValue ct = Arrays.stream(registration.getObjectLinks()).filter(link -> link.getUriReference().equals("/")).findFirst().get().getLinkParams().get("ct"); LinkParamValue ct = Arrays.stream(registration.getObjectLinks())
.filter(link -> link.getUriReference().equals("/"))
.findFirst()
.map(link -> link.getLinkParams().get("ct")).orElse(null);
if (ct != null) { if (ct != null) {
Set<ContentFormat> codes = Stream.of(ct.getUnquoted().replaceAll("\"", "").split(" ", -1)) Set<ContentFormat> codes = Stream.of(ct.getUnquoted().replaceAll("\"", "").split(" ", -1))
.map(String::trim) .map(String::trim)

Loading…
Cancel
Save