Source:
public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.PUT == request.getMethod() || HttpServer.Method.POST == request.getMethod()) { ClientConfiguration adminConf = new ClientConfiguration(conf); BookKeeperAdmin admin = new BookKeeperAdmin(adminConf); String requestBody = request.getBody(); if (requestBody == null) { admin.close(); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Null request body for DecommissionService."); return response; } @SuppressWarnings("unchecked") HashMap<String, String> configMap = JsonUtil.fromJson(requestBody, HashMap.class); if (configMap != null && configMap.containsKey("bookie_src")) { try { String bookieSrcString[] = configMap.get("bookie_src").split(":"); BookieSocketAddress bookieSrc = new BookieSocketAddress( bookieSrcString[0], Integer.parseInt(bookieSrcString[1])); admin.decommissionBookie(bookieSrc); admin.close(); response.setCode(HttpServer.StatusCode.OK); response.setBody("Success decommission Bookie " + bookieSrc.toString()); return response; } catch (Exception e) { admin.close(); e.printStackTrace(); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Exception when do decommission." + e.getMessage()); return response; } } else { admin.close(); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Request body not contains bookie_src."); return response; } } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be PUT/POST method"); return response; } }

Target:
public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.PUT == request.getMethod()) { String requestBody = request.getBody(); if (requestBody == null) { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Null request body for DecommissionService."); return response; } @SuppressWarnings("unchecked") HashMap<String, String> configMap = JsonUtil.fromJson(requestBody, HashMap.class); if (configMap != null && configMap.containsKey("bookie_src")) { try { String bookieSrcString[] = configMap.get("bookie_src").split(":"); BookieSocketAddress bookieSrc = new BookieSocketAddress( bookieSrcString[0], Integer.parseInt(bookieSrcString[1])); executor.execute(() -> { try { LOG.info("Start decommissioning bookie."); bka.decommissionBookie(bookieSrc); LOG.info("Complete decommissioning bookie."); } catch (Exception e) { LOG.error("Error handling decommissionBookie: with exception {}", bookieSrc, e); } }); response.setCode(HttpServer.StatusCode.OK); response.setBody("Success send decommission Bookie command " + bookieSrc.toString()); return response; } catch (Exception e) { LOG.error("Exception occurred while decommissioning bookie: ", e); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Exception when send decommission command." + e.getMessage()); return response; } } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Request body not contains bookie_src."); return response; } } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be PUT method"); return response; } }