Make ServerProperties bean conditional on being a webapp

pull/1433/head
Dave Syer 10 years ago
parent a9d0815e0c
commit 171b2e452b

@ -122,7 +122,7 @@ public class ManagementSecurityAutoConfiguration {
@Autowired
private SecurityProperties security;
@Autowired
@Autowired(required = false)
private ServerProperties server;
@Override
@ -148,8 +148,10 @@ public class ManagementSecurityAutoConfiguration {
if (this.errorController != null) {
ignored.add(normalizePath(this.errorController.getErrorPath()));
}
String[] paths = this.server.getPathsArray(ignored);
ignoring.antMatchers(paths);
if (this.server != null) {
String[] paths = this.server.getPathsArray(ignored);
ignoring.antMatchers(paths);
}
}
private String normalizePath(String errorPath) {

@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
@ -55,6 +56,7 @@ public class ManagementServerPropertiesAutoConfiguration {
// In case server auto configuration hasn't been included
@Bean
@ConditionalOnMissingBean
@ConditionalOnWebApplication
public ServerProperties serverProperties() {
return new ServerProperties();
}

@ -316,6 +316,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
@SuppressWarnings("rawtypes")
AbstractProtocol protocol = (AbstractProtocol) handler;
protocol.setMaxThreads(Tomcat.this.maxThreads);
}
@ -329,6 +330,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
@SuppressWarnings("rawtypes")
AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize);
}

Loading…
Cancel
Save