Harmonize `accesslog.enabled` flag for Undertow

Closes gh-12178
This commit is contained in:
Stephane Nicoll 2018-02-23 11:26:33 +01:00
parent 09ff815f00
commit 92d1c6126b
3 changed files with 4 additions and 14 deletions

View File

@ -1058,7 +1058,7 @@ public class ServerProperties {
/**
* Whether to enable the access log.
*/
private Boolean enabled;
private boolean enabled = false;
/**
* Format pattern for access logs.
@ -1085,11 +1085,11 @@ public class ServerProperties {
*/
private boolean rotate = true;
public Boolean getEnabled() {
public boolean isEnabled() {
return this.enabled;
}
public void setEnabled(Boolean enabled) {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

View File

@ -69,7 +69,7 @@ public class UndertowWebServerFactoryCustomizer implements
.to(factory::setWorkerThreads);
propertyMapper.from(undertowProperties::getDirectBuffers)
.to(factory::setUseDirectBuffers);
propertyMapper.from(accesslogProperties::getEnabled)
propertyMapper.from(accesslogProperties::isEnabled)
.to(factory::setAccessLogEnabled);
propertyMapper.from(accesslogProperties::getDir)
.to(factory::setAccessLogDirectory);

View File

@ -29,9 +29,7 @@ import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebSer
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
@ -102,14 +100,6 @@ public class UndertowWebServerFactoryCustomizerTests {
verify(factory).setUseForwardHeaders(true);
}
@Test
public void skipNullElementsForUndertow() {
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
this.customizer.customize(factory);
verify(factory, never()).setAccessLogEnabled(anyBoolean());
}
private void bind(String... inlinedProperties) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
inlinedProperties);