Skip to content

Commit

Permalink
fix: Error in boolean check which prevents logging sometimes (#1314)
Browse files Browse the repository at this point in the history
I.e. when enabled is a Boolean but not identical to Boolean.TRUE

Fixes #1291
  • Loading branch information
rhuss authored Jan 8, 2020
1 parent 64aba10 commit b5bf2a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ChangeLog

* **0.31-SNAPSHOT**
- Support building dockerFile without pushing it to docker server #1197
- Support building dockerFile without pushing it to docker server (#1197)
- Update to jnr-unixsocket 0.23
- Add null check for null instance in config.json for email (#1262)
- Allow merging of image configurations using <imagesMap> ([#360](https://github.com/fabric8io/docker-maven-plugin/issues/360))
Expand All @@ -18,6 +18,7 @@
- Deprecated "authToken" for ECR authentication in favor of "auth" (#1286)
- Allow overriding of existing image in creation of temporary one with same tag before push ([#838](https://github.com/fabric8io/docker-maven-plugin/issues/838))
- Pick up AWS credentials from ENV variables (#1310)
- Fix accidentally disabled logging under certain conditions (#1291)

* **0.31.0** (2019-08-10)
- Fix test cases on Windows ([#1220](https://github.com/fabric8io/docker-maven-plugin/issues/1220))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public Boolean isEnabled() {
* @return
*/
public boolean isActivated() {
return enabled == Boolean.TRUE ||
(enabled != Boolean.FALSE && !isBlank());
return enabled != null ? enabled : !isBlank();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,33 @@ public void testNonEmptyBuiltConfiguration() {

@Test
public void testEnabled() {
LogConfiguration cfg = new LogConfiguration.Builder()
.enabled(true)
for (Boolean enabled : new Boolean[]{Boolean.TRUE, new Boolean(true)}) {
LogConfiguration cfg = new LogConfiguration.Builder()
.enabled(enabled)
.build();
assertTrue(cfg.isEnabled());
assertTrue(cfg.isActivated());
assertTrue(cfg.isEnabled());
assertTrue(cfg.isActivated());

cfg = new LogConfiguration.Builder()
cfg = new LogConfiguration.Builder()
.enabled(true)
.color("red")
.build();
assertTrue(cfg.isEnabled());
assertTrue(cfg.isActivated());
assertEquals("red", cfg.getColor());
assertTrue(cfg.isEnabled());
assertTrue(cfg.isActivated());
assertEquals("red", cfg.getColor());
}
}

@Test
public void testDisabled() {
LogConfiguration cfg = new LogConfiguration.Builder()
for (Boolean disabled : new Boolean[]{Boolean.FALSE, new Boolean(false)}) {
LogConfiguration cfg = new LogConfiguration.Builder()
.color("red")
.enabled(false)
.enabled(disabled)
.build();
assertFalse(cfg.isEnabled());
assertFalse(cfg.isActivated());
assertEquals("red", cfg.getColor());
assertFalse(cfg.isEnabled());
assertFalse(cfg.isActivated());
assertEquals("red", cfg.getColor());
}
}
}

0 comments on commit b5bf2a7

Please sign in to comment.