Merge branch '1.3.x'

This commit is contained in:
Phillip Webb
2016-04-09 23:53:26 -07:00
9 changed files with 241 additions and 26 deletions

View File

@@ -961,14 +961,30 @@ public class ServerProperties
void customizeUndertow(ServerProperties serverProperties,
UndertowEmbeddedServletContainerFactory factory) {
factory.setBufferSize(this.bufferSize);
factory.setBuffersPerRegion(this.buffersPerRegion);
factory.setIoThreads(this.ioThreads);
factory.setWorkerThreads(this.workerThreads);
factory.setDirectBuffers(this.directBuffers);
factory.setAccessLogDirectory(this.accesslog.dir);
factory.setAccessLogPattern(this.accesslog.pattern);
factory.setAccessLogEnabled(this.accesslog.enabled);
if (this.bufferSize != null) {
factory.setBufferSize(this.bufferSize);
}
if (this.buffersPerRegion != null) {
factory.setBuffersPerRegion(this.buffersPerRegion);
}
if (this.ioThreads != null) {
factory.setIoThreads(this.ioThreads);
}
if (this.workerThreads != null) {
factory.setWorkerThreads(this.workerThreads);
}
if (this.directBuffers != null) {
factory.setDirectBuffers(this.directBuffers);
}
if (this.accesslog.dir != null) {
factory.setAccessLogDirectory(this.accesslog.dir);
}
if (this.accesslog.pattern != null) {
factory.setAccessLogPattern(this.accesslog.pattern);
}
if (this.accesslog.enabled != null) {
factory.setAccessLogEnabled(this.accesslog.enabled);
}
factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders());
}
@@ -977,7 +993,7 @@ public class ServerProperties
/**
* Enable access log.
*/
private boolean enabled = false;
private Boolean enabled;
/**
* Format pattern for access logs.
@@ -989,11 +1005,11 @@ public class ServerProperties
*/
private File dir = new File("logs");
public boolean isEnabled() {
public Boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

View File

@@ -48,6 +48,7 @@ import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -418,6 +419,14 @@ public class ServerPropertiesTests {
verify(container).setSessionStoreDir(new File("myfolder"));
}
@Test
public void skipNullElementsForUndertow() throws Exception {
UndertowEmbeddedServletContainerFactory container = mock(
UndertowEmbeddedServletContainerFactory.class);
this.properties.customize(container);
verify(container, never()).setAccessLogEnabled(anyBoolean());
}
private void bindProperties(Map<String, String> map) {
new RelaxedDataBinder(this.properties, "server")
.bind(new MutablePropertyValues(map));