Source:
private void sendServers(final BootstrapSession bsSession, final BootstrapConfig cfg, final List<Integer> toSend) { if (!toSend.isEmpty()) { Integer key = toSend.remove(0); ServerConfig serverConfig = cfg.servers.get(key); LwM2mPath path = new LwM2mPath(1, key); final LwM2mNode serverInstance = convertToServerInstance(key, serverConfig); send(bsSession, new BootstrapWriteRequest(path, serverInstance, ContentFormat.TLV), new ResponseCallback<BootstrapWriteResponse>() { @Override public void onResponse(BootstrapWriteResponse response) { LOG.debug("Bootstrap write return code {}", bsSession.getEndpoint(), response.getCode()); sendServers(bsSession, cfg, toSend); } }, new ErrorCallback() { @Override public void onError(Exception e) { LOG.warn(String.format("Error pending bootstrap write of server instance %s on %s", serverInstance, bsSession.getEndpoint()), e); } }); } else { send(bsSession, new BootstrapFinishRequest(), new ResponseCallback<BootstrapFinishResponse>() { @Override public void onResponse(BootstrapFinishResponse response) { LOG.debug("Bootstrap Finished return code {}", bsSession.getEndpoint(), response.getCode()); if (response.isSuccess()) { bsSessionManager.end(bsSession); } } }, new ErrorCallback() { @Override public void onError(Exception e) { LOG.warn(String.format("Error pending bootstrap finished on %s", bsSession.getEndpoint()), e); } }); } }

Target:
private void sendServers(final BootstrapSession bsSession, final BootstrapConfig cfg, final List<Integer> toSend) { if (!toSend.isEmpty()) { Integer key = toSend.remove(0); ServerConfig serverConfig = cfg.servers.get(key); LwM2mPath path = new LwM2mPath(1, key); final LwM2mNode serverInstance = convertToServerInstance(key, serverConfig); final BootstrapWriteRequest writeServerRequest = new BootstrapWriteRequest(path, serverInstance, ContentFormat.TLV); send(bsSession, writeServerRequest, new ResponseCallback<BootstrapWriteResponse>() { @Override public void onResponse(BootstrapWriteResponse response) { LOG.debug("Bootstrap write return code {}", bsSession.getEndpoint(), response.getCode()); sendServers(bsSession, cfg, toSend); } }, new ErrorCallback() { @Override public void onError(Exception e) { LOG.warn(String.format("Error pending bootstrap write of server instance %s on %s", serverInstance, bsSession.getEndpoint()), e); bsSessionManager.failed(bsSession, writeServerRequest, e); } }); } else { final BootstrapFinishRequest finishBootstrapRequest = new BootstrapFinishRequest(); send(bsSession, finishBootstrapRequest, new ResponseCallback<BootstrapFinishResponse>() { @Override public void onResponse(BootstrapFinishResponse response) { LOG.debug("Bootstrap Finished return code {}", bsSession.getEndpoint(), response.getCode()); if (response.isSuccess()) { bsSessionManager.end(bsSession); } else { bsSessionManager.failed(bsSession, finishBootstrapRequest, new RuntimeException( String.format("Bootstrap finished with response code : %s", response))); } } }, new ErrorCallback() { @Override public void onError(Exception e) { LOG.warn(String.format("Error pending bootstrap finished on %s", bsSession.getEndpoint()), e); bsSessionManager.failed(bsSession, finishBootstrapRequest, e); } }); } }