Skip to content

Commit

Permalink
Avoiding NPE #127
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 1, 2019
1 parent 5e2e67f commit 7a66549
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion run.sh
@@ -1,3 +1,3 @@
#!/bin/sh
mvn versions:update-properties
mvn hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.150.1 -Denforcer.skip=true
mvn hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.181 -Denforcer.skip=true
5 changes: 3 additions & 2 deletions src/main/java/org/jenkinsci/plugins/gwt/Renderer.java
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.gwt;

import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Strings.nullToEmpty;
import static java.util.logging.Level.FINE;
import static java.util.regex.Pattern.compile;

Expand All @@ -25,8 +26,8 @@ public static boolean isMatching(
return true;
}
final boolean isMatching =
compile(regexpFilterExpression) //
.matcher(renderedRegexpFilterText) //
compile(nullToEmpty(regexpFilterExpression)) //
.matcher(nullToEmpty(renderedRegexpFilterText)) //
.find();
if (!isMatching) {
LOGGER.log(
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/jenkinsci/plugins/gwt/RendererTest.java
Expand Up @@ -41,6 +41,26 @@ public void testThatEmptyTextIsNotMatched() {
.isFalse();
}

@Test
public void testThatEmptyExprButNotEmptyTextIsNotMatched() {
assertThat(isMatching(null, "^feature")) //
.isFalse();
assertThat(isMatching("", "^feature")) //
.isFalse();
}

@Test
public void testThatEmptyExprAndEmptyTextIsMatched() {
assertThat(isMatching(null, "")) //
.isTrue();
assertThat(isMatching("", null)) //
.isTrue();
assertThat(isMatching(null, null)) //
.isTrue();
assertThat(isMatching("", "")) //
.isTrue();
}

@Test
public void testThatIsMatchingWorksDevelopCorrectUser() {
regexpFilterText = "refs/heads/develop tomabje";
Expand Down

0 comments on commit 7a66549

Please sign in to comment.