Skip to content
Permalink
Browse files

[FIXED JENKINS-29134] cont.

* 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 25537f0cfc97bbd0702e6b4a27e8306a0cafbac3
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java
@@ -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);
@@ -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).

0 comments on commit 25537f0

Please sign in to comment.
You can’t perform that action at this time.