Skip to content

Commit

Permalink
Fix NPE when Spring Boot Maven Plugin doesn't have <configuration> (#…
Browse files Browse the repository at this point in the history
…2688)

* Fix NPE when null spring-boot configuration
* Use Boolean.parseBoolean / fix CHANGELOG typo
  • Loading branch information
chanseokoh authored Aug 10, 2020
1 parent 7b36544 commit 0af20a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions jib-maven-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fixed `NullPointerException` when the Spring Boot Maven plugin does not have a `<configuration>` block. ([#2687](https://github.com/GoogleContainerTools/jib/issues/2687))

## 2.5.0

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ Optional<Xpp3Dom> getSpringBootRepackageConfiguration() {
if (execution.getGoals().contains("repackage")) {
Xpp3Dom configuration = (Xpp3Dom) execution.getConfiguration();

boolean skip = Boolean.valueOf(getChildValue(configuration, "skip").orElse("false"));
return skip ? Optional.empty() : Optional.of(configuration);
boolean skip = Boolean.parseBoolean(getChildValue(configuration, "skip").orElse("false"));
return skip ? Optional.empty() : Optional.ofNullable(configuration);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,17 @@ public void testGetSpringBootRepackageConfiguration_pluginNotApplied() {
Optional.empty(), mavenProjectProperties.getSpringBootRepackageConfiguration());
}

@Test
public void testGetSpringBootRepackageConfiguration_noConfigurationBlock() {
Mockito.when(mockMavenProject.getPlugin("org.springframework.boot:spring-boot-maven-plugin"))
.thenReturn(mockPlugin);
Mockito.when(mockPlugin.getExecutions()).thenReturn(Arrays.asList(mockPluginExecution));
Mockito.when(mockPluginExecution.getGoals()).thenReturn(Arrays.asList("repackage"));
Mockito.when(mockPluginExecution.getConfiguration()).thenReturn(null);
Assert.assertEquals(
Optional.empty(), mavenProjectProperties.getSpringBootRepackageConfiguration());
}

@Test
public void testGetSpringBootRepackageConfiguration_noExecutions() {
Mockito.when(mockMavenProject.getPlugin("org.springframework.boot:spring-boot-maven-plugin"))
Expand Down

0 comments on commit 0af20a3

Please sign in to comment.