Source:
<code>public void handlePUT(final CoapExchange coapExchange) { ServerIdentity identity = extractServerIdentity(coapExchange, bootstrapHandler); String URI = coapExchange.getRequestOptions().getUriPathString(); ObserveSpec spec = null; if (coapExchange.advanced().getRequest().getOptions().getURIQueryCount() != 0) { final List<String> uriQueries = coapExchange.advanced().getRequest().getOptions().getUriQuery(); spec = ObserveSpec.parse(uriQueries); } if (spec != null) { WriteAttributesResponse response = nodeEnabler.writeAttributes(identity, new WriteAttributesRequest(URI, spec)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); return; } else { LwM2mPath path = new LwM2mPath(URI); if (!coapExchange.getRequestOptions().hasContentFormat()) { coapExchange.respond(ResponseCode.BAD_REQUEST, "Content Format is mandatory"); return; } ContentFormat contentFormat = ContentFormat.fromCode(coapExchange.getRequestOptions().getContentFormat()); if (!decoder.isSupported(contentFormat)) { coapExchange.respond(ResponseCode.UNSUPPORTED_CONTENT_FORMAT); return; } LwM2mNode lwM2mNode; try { LwM2mModel model = new LwM2mModel(nodeEnabler.getObjectModel()); lwM2mNode = decoder.decode(coapExchange.getRequestPayload(), contentFormat, path, model); if (identity.isLwm2mBootstrapServer()) { BootstrapWriteResponse response = nodeEnabler.write(identity, new BootstrapWriteRequest(path, lwM2mNode, contentFormat)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); } else { WriteResponse response = nodeEnabler.write(identity, new WriteRequest(Mode.REPLACE, contentFormat, URI, lwM2mNode)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); } return; } catch (CodecException e) { LOG.warn("Unable to decode payload to write", e); <START> coapExchange.respond(ResponseCode.INTERNAL_SERVER_ERROR); <END> return; } } }</code><technical_language>BAD_REQUEST</technical_language>

Target:
public void handlePUT(final CoapExchange coapExchange) { ServerIdentity identity = extractServerIdentity(coapExchange, bootstrapHandler); String URI = coapExchange.getRequestOptions().getUriPathString(); ObserveSpec spec = null; if (coapExchange.advanced().getRequest().getOptions().getURIQueryCount() != 0) { final List<String> uriQueries = coapExchange.advanced().getRequest().getOptions().getUriQuery(); spec = ObserveSpec.parse(uriQueries); } if (spec != null) { WriteAttributesResponse response = nodeEnabler.writeAttributes(identity, new WriteAttributesRequest(URI, spec)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); return; } else { LwM2mPath path = new LwM2mPath(URI); if (!coapExchange.getRequestOptions().hasContentFormat()) { coapExchange.respond(ResponseCode.BAD_REQUEST, "Content Format is mandatory"); return; } ContentFormat contentFormat = ContentFormat.fromCode(coapExchange.getRequestOptions().getContentFormat()); if (!decoder.isSupported(contentFormat)) { coapExchange.respond(ResponseCode.UNSUPPORTED_CONTENT_FORMAT); return; } LwM2mNode lwM2mNode; try { LwM2mModel model = new LwM2mModel(nodeEnabler.getObjectModel()); lwM2mNode = decoder.decode(coapExchange.getRequestPayload(), contentFormat, path, model); if (identity.isLwm2mBootstrapServer()) { BootstrapWriteResponse response = nodeEnabler.write(identity, new BootstrapWriteRequest(path, lwM2mNode, contentFormat)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); } else { WriteResponse response = nodeEnabler.write(identity, new WriteRequest(Mode.REPLACE, contentFormat, URI, lwM2mNode)); coapExchange.respond(fromLwM2mCode(response.getCode()), response.getErrorMessage()); } return; } catch (CodecException e) { LOG.warn("Unable to decode payload to write", e); coapExchange.respond(ResponseCode.BAD_REQUEST); return; } } }