Skip to content

Commit

Permalink
[FIXED JENKINS-29134] cont.
Browse files Browse the repository at this point in the history
* Added null-check for user-input.
* Trimming user-input.

Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
  • Loading branch information
Bagira80 committed Jul 15, 2015
1 parent 5a669b5 commit 25537f0
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -155,7 +155,9 @@ private static Date parseDate(String dateString) {
* @return The given <a>buildNum</a> if valid or an empty string.
*/
private static String makeValid(String buildNum) {
if (buildNum == null) return ""; // Return the default-value.
try {
buildNum = buildNum.trim();
// If we got a valid integer the following conversion will
// succeed without an exception.
Integer intVal = new Integer(buildNum);
Expand All @@ -166,7 +168,7 @@ private static String makeValid(String buildNum) {
} catch (Exception e) {
// Obviously, we did not receive a valid integer as override.
// Is it a reference to an environment-variable?
if (buildNum != null && buildNum.matches(envVarPattern)) {
if (buildNum.matches(envVarPattern)) {
// Yes, so return it as-is and only retrieve its value when
// the value must be accessed (to always get the most
// up-to-date value).
Expand Down

0 comments on commit 25537f0

Please sign in to comment.