Skip to content

Commit

Permalink
Improve reliabilty of lazy-loaded objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimilian committed Feb 13, 2018
1 parent 6fa18a4 commit 959a2da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String getName() {
*/
public Map<Change, PatchSet> getChanges(GerritQueryHandler gerritQueryHandler) {
if (changes == null) {
changes = new HashMap<Change, PatchSet>();
Map<Change, PatchSet> temp = new HashMap<Change, PatchSet>();
try {
List<JSONObject> jsonList = gerritQueryHandler.queryCurrentPatchSets("topic:{" + name + "}");
for (JSONObject json : jsonList) {
Expand All @@ -81,13 +81,15 @@ public Map<Change, PatchSet> getChanges(GerritQueryHandler gerritQueryHandler) {
}
if (json.has("currentPatchSet")) {
JSONObject currentPatchSet = json.getJSONObject("currentPatchSet");
changes.put(new Change(json), new PatchSet(currentPatchSet));
temp.put(new Change(json), new PatchSet(currentPatchSet));
}
}
changes = temp;
} catch (IOException e) {
logger.error("IOException occured. ", e);
} catch (GerritQueryException e) {
logger.error("Bad query. ", e);

}
}
return changes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


Expand All @@ -29,7 +28,7 @@ private FileHelper() {
* Provides list of files related to the change.
* @param gerritQueryHandler the query handler, responsible for the queries to gerrit.
* @param changeId the Gerrit change id.
* @return list of files from the change.
* @return list of files from the change, null in case of errors
*/
public static List<String> getFilesByChange(GerritQueryHandler gerritQueryHandler, String changeId) {
try {
Expand Down Expand Up @@ -58,10 +57,10 @@ public static List<String> getFilesByChange(GerritQueryHandler gerritQueryHandle
}
}
} catch (IOException e) {
logger.error("IOException occured. ", e);
logger.error("IOException occurred. ", e);
} catch (GerritQueryException e) {
logger.error("Bad query. ", e);
}
return Collections.emptyList();
return null;
}
}

0 comments on commit 959a2da

Please sign in to comment.