Skip to content

Commit

Permalink
Fix projectListRefreshInterval zero value after upgrade from 2.13.0 t…
Browse files Browse the repository at this point in the history
…o 2.14.0

[FIXED JENKINS-31800]
  • Loading branch information
engycz committed Jan 5, 2016
1 parent 82faa6e commit 78f4c5c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
Expand Up @@ -1260,19 +1260,6 @@ public FormValidation doDynamicConfigRefreshCheck(
return FormValidation.ok();
}

/**
* Checks that the provided parameter is an integer, not negative.
*
* @param value the value.
* @return {@link FormValidation#validatePositiveInteger(String)}
*/
public FormValidation doProjectListFetchDelayCheck(
@QueryParameter("value")
final String value) {

return FormValidation.validateNonNegativeInteger(value);
}

/**
* Checks that the provided parameter is an integer.
* @param value the value.
Expand Down
Expand Up @@ -644,6 +644,9 @@ public int getProjectListFetchDelay() {

@Override
public int getProjectListRefreshInterval() {
if (projectListRefreshInterval == 0) {
projectListRefreshInterval = DEFAULT_PROJECT_LIST_REFRESH_INTERVAL;
}
return projectListRefreshInterval;
}

Expand Down
Expand Up @@ -251,7 +251,7 @@
<f:textbox name="projectListFetchDelay"
value="${it.config.projectListFetchDelay}"
default="${com.sonyericsson.gerrithudsontrigger.config.Config.DEFAULT_PROJECT_LIST_FETCH_DELAY}"
checkUrl="'${rootURL}/${serverURL}/projectListFetchDelayCheck?value='+escape(this.value)"
checkUrl="'${rootURL}/${serverURL}/nonNegativeIntegerCheck?value='+escape(this.value)"
style="max-width: 100px;"/>
</div>
</div>
Expand All @@ -263,7 +263,7 @@
<f:textbox name="projectListRefreshInterval"
value="${it.config.projectListRefreshInterval}"
default="${com.sonyericsson.gerrithudsontrigger.config.Config.DEFAULT_PROJECT_LIST_REFRESH_INTERVAL}"
checkUrl="'${rootURL}/${serverURL}/projectListFetchDelayCheck?value='+escape(this.value)"
checkUrl="'${rootURL}/${serverURL}/positiveIntegerCheck?value='+escape(this.value)"
style="max-width: 100px;"/>
</div>
</div>
Expand Down
Expand Up @@ -139,6 +139,19 @@ public void testSetValues() {

//CS IGNORE MagicNumber FOR NEXT 100 LINES. REASON: Mocks tests.

/**
* Test ProjectListRefreshInterval zero value after upgrade from gerrit-trigger version 2.13.0 to 2.14.0.
*/
@Test
public void testProjectListRefreshIntervalZeroValue() {
String formString = "{\"projectListRefreshInterval\":\"0\"}";
JSONObject form = (JSONObject)JSONSerializer.toJSON(formString);
Config config = new Config(form);
assertEquals(config.DEFAULT_PROJECT_LIST_REFRESH_INTERVAL, config.getProjectListRefreshInterval());
}

//CS IGNORE MagicNumber FOR NEXT 100 LINES. REASON: Mocks tests.

/**
* Test creation of a config object from an existing one.
*/
Expand Down

0 comments on commit 78f4c5c

Please sign in to comment.