Lwm2m: backEnd: fix bug getResourceValueToString NullPointExaption
This commit is contained in:
parent
02615cb93d
commit
e91cb65399
@ -311,7 +311,7 @@ public class LwM2MTransportRequest {
|
||||
try {
|
||||
sendResponse(registration, path, response, request, lwM2MClient, isDelayedUpdate);
|
||||
} catch (Exception e) {
|
||||
log.error("[{}] endpoint [{}] path [{}] error Unable to after send response.", registration.getEndpoint(), path, e);
|
||||
log.error("[{}] endpoint [{}] path [{}] Exception Unable to after send response.", registration.getEndpoint(), path, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -321,7 +321,7 @@ public class LwM2MTransportRequest {
|
||||
try {
|
||||
if (isDelayedUpdate) lwM2MClient.onSuccessOrErrorDelayedRequests(path);
|
||||
} catch (RuntimeException t) {
|
||||
log.error("[{}] endpoint [{}] path [{}] error Unable to after send response.", registration.getEndpoint(), path, t.toString());
|
||||
log.error("[{}] endpoint [{}] path [{}] RuntimeException Unable to after send response.", registration.getEndpoint(), path, t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -415,7 +415,6 @@ public class LwM2MTransportService {
|
||||
List listV = new ArrayList<TransportProtos.KeyValueProto>();
|
||||
listV.add(v.getKv());
|
||||
this.putDelayedUpdateResourcesClient(lwM2MClient, this.getResourceValueToString(lwM2MClient, k), getJsonObject(listV).get(v.getKv().getKey()), k);
|
||||
System.out.printf(" k: %s, v: %s%n, v1: %s%n", k, v.getKv().getStringV(), this.getResourceValueToString(lwM2MClient, k));
|
||||
});
|
||||
lwM2MClient.getDelayedRequestsId().remove(attributesResponse.getRequestId());
|
||||
if (lwM2MClient.getDelayedRequests().size() == 0) {
|
||||
@ -425,7 +424,7 @@ public class LwM2MTransportService {
|
||||
}
|
||||
|
||||
private void putDelayedUpdateResourcesClient(LwM2MClient lwM2MClient, Object valueOld, Object valueNew, String path) {
|
||||
if (!valueOld.toString().equals(valueNew.toString())) {
|
||||
if (valueNew != null && !valueNew.toString().equals(valueOld.toString())) {
|
||||
lwM2MTransportRequest.sendAllRequest(lwM2MClient.getLwServer(), lwM2MClient.getRegistration(), path, POST_TYPE_OPER_WRITE_REPLACE,
|
||||
ContentFormat.TLV.getName(), lwM2MClient, null, valueNew, this.context.getCtxServer().getTimeout(),
|
||||
true);
|
||||
@ -1160,7 +1159,7 @@ public class LwM2MTransportService {
|
||||
public String getResourceValueToString(LwM2MClient lwM2MClient, String path) {
|
||||
LwM2mPath pathIds = new LwM2mPath(path);
|
||||
ResourceValue resourceValue = this.getResourceValue(lwM2MClient, pathIds);
|
||||
return (String) this.converter.convertValue(resourceValue.getResourceValue(), this.context.getCtxServer().getResourceModelType(pathIds), ResourceModel.Type.STRING, pathIds);
|
||||
return (resourceValue == null) ? null :
|
||||
(String) this.converter.convertValue(resourceValue.getResourceValue(), this.context.getCtxServer().getResourceModelType(pathIds), ResourceModel.Type.STRING, pathIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -104,7 +104,6 @@ public class LwM2MClient implements Cloneable {
|
||||
if (objectModel != null) {
|
||||
((LwM2mObjectInstance)((ReadResponse)resp).getContent()).getResources().forEach((k, v) -> {
|
||||
String rez = pathIds.toString() + "/" + k;
|
||||
boolean ismulti = objectModel.resources.get(k).multiple;
|
||||
if (objectModel.resources.get(k).multiple){
|
||||
this.resources.put(rez, new ResourceValue(v.getValues(), null, true));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user