Skip to content
Browse files
Include the latest patchset only in manual trigger page
Gerrit search in manual trigger page shows all patchsets in a change.
But session needs much memory if result has many rows.
It causes poor PermGen space.

This patch adds a feature that includes the latest patchset only in
search result.

Fix for JENKINS-21064

  • Loading branch information
rinrinne committed Sep 16, 2014
1 parent 8804f89 commit 8a9839ce165620fd045d062e897c5ca186a52fb9
@@ -278,20 +278,23 @@ public String toReadableHtml(String subject) {
* @param queryString the query to send to Gerrit.
* @param request the request.
* @param selectedServer the selected Gerrit server.
* @param allPatchSets if the result includes all patchsets in a change.
* @param response the response.
* @throws IOException if the query fails.
//Called from jelly
public void doGerritSearch(@QueryParameter("queryString") final String queryString,
@QueryParameter("selectedServer") final String selectedServer, StaplerRequest request,
@QueryParameter("selectedServer") final String selectedServer,
@QueryParameter("allPatchSets") final boolean allPatchSets, StaplerRequest request,
StaplerResponse response) throws IOException {

HttpSession session = request.getSession();
// Create session if nothing.
if (session == null) {
session = request.getSession(true);
session.setAttribute("allPatchSets", allPatchSets);
session.setAttribute("selectedServer", selectedServer);
if (!isServerEnabled(selectedServer)) {
@@ -306,7 +309,17 @@ public void doGerritSearch(@QueryParameter("queryString") final String queryStri
session.setAttribute("queryString", queryString);

try {
List<JSONObject> json = handler.queryJava(queryString, true, true, false);
List<JSONObject> json = handler.queryJava(queryString, allPatchSets, true, false);
if (!allPatchSets) {
for (JSONObject j : json) {
if (j.containsKey("id")) {
JSONArray jsonArray = new JSONArray();
j.put("patchSets", jsonArray);
session.setAttribute(SESSION_RESULT, json);
//TODO Implement some smart default selection.
//That can notice that a specific revision is searched or that there is only one result etc.
@@ -0,0 +1,5 @@
<p>Check if you want to get all patchsets in a change by query.</p>

<p>If disabled, result includes the latest patchset only.</p>
@@ -0,0 +1,5 @@

@@ -54,6 +54,12 @@
<f:entry title="${%Include All Patchsets}"
<f:checkbox name="allPatchSets"
<f:submit value="${%Search}"/>

0 comments on commit 8a9839c

Please sign in to comment.