Source:
private static Map<String, Long> searchIssues(ZephyrConfigModel zephyrData) { long searchIssueStartcount = -1L; long totalIssueCount = 0L; long searchedIsssuesCount = 0L; final Map<String, Long> searchedTests = new HashMap<String, Long>(); do { final String isssueSearchURL = String.format(URL_GET_ALL_TESTS, zephyrData.getRestClient().getUrl(), zephyrData.getProjectId(), zephyrData.getTestIssueTypeId(), searchIssueStartcount, searchIssueStartcount); JsonArray searchedIssues = null; final CloseableHttpResponse response = zephyrData.getRestClient().get(isssueSearchURL); 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 (IOException e) { ZephyrPlugin.log(e); } final JsonObject testCaseIssues = new JsonParser().parse(string).getAsJsonObject(); totalIssueCount = testCaseIssues.get("total").getAsLong(); searchedIssues = testCaseIssues.get("issues").getAsJsonArray(); searchedIsssuesCount += searchedIssues.size(); } else { ZephyrPlugin.log("Unexpected response status: " + statusCode); } if (searchedIssues != null && searchedIssues.size() > 0) { for (int i = 0; i < searchedIssues.size(); i++) { final JsonObject jsonObject = searchedIssues.get(i).getAsJsonObject(); final long testId = jsonObject.get("id").getAsLong(); final String testKey = jsonObject.get("key").getAsString().trim(); searchedTests.put(testKey, testId); } } if (response != null) { try { response.close(); } catch (IOException e) { ZephyrPlugin.log(e); } } } while (searchedIsssuesCount < totalIssueCount); return searchedTests; }

Target:
private static Map<String, Long> searchIssues(ZephyrConfigModel zephyrData) { long searchIssueStartcount = -1L; long totalIssueCount = 0L; long searchedIsssuesCount = 0L; final Map<String, Long> searchedTests = new HashMap<String, Long>(); do { final String url = String.format(URL_GET_ALL_TESTS, zephyrData.getRestClient().getUrl(), zephyrData.getProjectId(), zephyrData.getTestIssueTypeId(), searchIssueStartcount, searchIssueStartcount); JsonArray searchedIssues = null; try (final CloseableHttpResponse response = zephyrData.getRestClient().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 (IOException e) { throw new IllegalArgumentException( String.format("Bad response entity upon receipt of issues <%s>", url), e); } final JsonObject testCaseIssues = new JsonParser().parse(string).getAsJsonObject(); totalIssueCount = testCaseIssues.get("total").getAsLong(); searchedIssues = testCaseIssues.get("issues").getAsJsonArray(); searchedIsssuesCount += searchedIssues.size(); } else { throw new IllegalArgumentException(String .format("Unexpected response status <%s> upon receipt of issues <%s>", statusCode, url)); } if (searchedIssues != null && searchedIssues.size() > 0) { for (int i = 0; i < searchedIssues.size(); i++) { final JsonObject jsonObject = searchedIssues.get(i).getAsJsonObject(); final long testId = jsonObject.get("id").getAsLong(); final String testKey = jsonObject.get("key").getAsString().trim(); searchedTests.put(testKey, testId); } } } catch (IOException e) { throw new IllegalArgumentException(e); } } while (searchedIsssuesCount < totalIssueCount); return searchedTests; }