Source:
public static Map<String, Long> getAllProjects(ZephyrRestClient restClient) { final Map<String, Long> projects = new HashMap<>(); final String url = String.format(URL_GET_PROJECTS, restClient.getUrl()); final HttpResponse response = restClient.get(url); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { final HttpEntity entity = response.getEntity(); String string = null; try { string = EntityUtils.toString(entity); } catch (ParseException | IOException e) { e.printStackTrace(); } final JsonObject projObject = new JsonParser().parse(string).getAsJsonObject(); final JsonArray projArray = projObject.get("projects").getAsJsonArray(); for (int i = 0; i < projArray.size(); i++) { final JsonObject project = projArray.get(i).getAsJsonObject(); final Long id = project.get("id").getAsLong(); final String projName = project.get("name").getAsString(); final JsonArray issueTypes = project.get("issuetypes").getAsJsonArray(); boolean issueTypeTesstExists = false; for (int j = 0; j < issueTypes.size(); j++) { final JsonObject issueType = issueTypes.get(j).getAsJsonObject(); final String issueTypeName = issueType.get("name").getAsString(); if (issueTypeName.trim().equalsIgnoreCase(TEST_ISSSUETYPE_NAME)) { issueTypeTesstExists = true; break; } } if (!issueTypeTesstExists) { continue; } projects.put(projName, id); } } else { ZephyrPlugin.log("Unexpected response status: " + statusCode); } return projects; }

Target:
public static Map<String, Long> getAllProjects(ZephyrRestClient restClient) { final Map<String, Long> projects = new HashMap<>(); final String url = String.format(URL_GET_PROJECTS, restClient.getUrl()); try (final CloseableHttpResponse response = restClient.get(url)) { final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { final HttpEntity entity = response.getEntity(); String string = null; try { string = EntityUtils.toString(entity); } catch (ParseException | IOException e) { throw new IllegalArgumentException( String.format("Bad response entity upon receipt of projects <%s>", url), e); } final JsonObject projObject = new JsonParser().parse(string).getAsJsonObject(); final JsonArray projArray = projObject.get("projects").getAsJsonArray(); for (int i = 0; i < projArray.size(); i++) { final JsonObject project = projArray.get(i).getAsJsonObject(); final Long id = project.get("id").getAsLong(); final String projName = project.get("name").getAsString(); final JsonArray issueTypes = project.get("issuetypes").getAsJsonArray(); boolean issueTypeTesstExists = false; for (int j = 0; j < issueTypes.size(); j++) { final JsonObject issueType = issueTypes.get(j).getAsJsonObject(); final String issueTypeName = issueType.get("name").getAsString(); if (issueTypeName.trim().equalsIgnoreCase(TEST_ISSSUETYPE_NAME)) { issueTypeTesstExists = true; break; } } if (!issueTypeTesstExists) { continue; } projects.put(projName, id); } } else { throw new IllegalArgumentException(String .format("Unexpected response status <%s> upon receipt of projects <%s>", statusCode, url)); } } catch (IOException e) { throw new IllegalArgumentException(e); } return projects; }