Source:
public JSONObject getFormData(String processId, String host, int port, String username, String password) throws JSONException, IOException { HttpGet httpGet = null; String line; JSONObject rsltObj; JSONObject rtrnObj = new JSONObject(); setHttpClient(host, port); String processDefId = processId; try (CloseableHttpResponse response = null; BufferedReader rd = null) { httpGet = new HttpGet(baseUrl + "/bpmn/process-definition/" + processDefId + "/properties"); httpGet.addHeader(BPMNExplorerServiceConstants.CONTENT_TYPE, BPMNExplorerServiceConstants.JSON_CONTENT_TYPE); String authString = username + ":" + password; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); httpGet.addHeader(BPMNExplorerServiceConstants.AUTHORIZATION, BPMNExplorerServiceConstants.BASIC_AUTHORIZATION + new String(authEncBytes)); response = client.execute(httpGet); rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.defaultCharset())); StringBuffer rsltForm = new StringBuffer(); while ((line = rd.readLine()) != null) { rsltForm.append(line); } rsltObj = new JSONObject(rsltForm.toString()); if (!rsltObj.has("data") && rsltObj.has("errorMessage")) { rtrnObj.put("error-message", rsltObj.get("errorMessage")); } else { JSONArray formData = new JSONObject(rsltForm.toString()).getJSONArray("data"); if (formData.length() <= 0) { rtrnObj = createProcessInstance(processDefId, username, password); } else { rtrnObj.put("processDefId", processDefId); rtrnObj.put("formData", formData); } } } catch (ClientProtocolException | IOException e) { log.error("Exception : ", e); } finally { if (httpGet != null) { httpGet.releaseConnection(); } } return rtrnObj; }

Target:
public JSONObject getFormData(String processId, String host, int port, String username, String password) throws JSONException, IOException { HttpGet httpGet = null; String line; JSONObject rsltObj; JSONObject rtrnObj = new JSONObject(); setHttpClient(host, port); String processDefId = processId; try (CloseableHttpResponse response = null; BufferedReader rd = null) { httpGet = new HttpGet(baseUrl + "/bpmn/process-definition/" + processDefId + "/properties"); httpGet.addHeader(Constants.CONTENT_TYPE, Constants.JSON_CONTENT_TYPE); String authString = username + ":" + password; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); httpGet.addHeader(Constants.AUTHORIZATION, Constants.BASIC_AUTHORIZATION + new String(authEncBytes)); response = client.execute(httpGet); rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.defaultCharset())); StringBuffer rsltForm = new StringBuffer(); while ((line = rd.readLine()) != null) { rsltForm.append(line); } rsltObj = new JSONObject(rsltForm.toString()); if (!rsltObj.has(Constants.DATA) && rsltObj.has(Constants.ERROR_MSG)) { rtrnObj.put(Constants.ERROR_MESSAGE, rsltObj.get(Constants.ERROR_MSG)); } else { JSONArray formData = new JSONObject(rsltForm.toString()).getJSONArray(Constants.DATA); if (formData.length() <= 0) { rtrnObj = createProcessInstance(processDefId, username, password); } else { rtrnObj.put("processDefId", processDefId); rtrnObj.put("formData", formData); } } } catch (ClientProtocolException e) { log.error(Constants.CLIENT_PROTOCOL_EX, e); } finally { if (httpGet != null) { httpGet.releaseConnection(); } } return rtrnObj; }