Polish
This commit is contained in:
parent
982e922c0b
commit
b20b5edf2a
|
@ -77,10 +77,7 @@ class HazelcastServerConfiguration {
|
|||
|
||||
private Config loadConfig(Resource configLocation) throws IOException {
|
||||
URL configUrl = configLocation.getURL();
|
||||
Config config;
|
||||
try (InputStream stream = configUrl.openStream()) {
|
||||
config = Config.loadFromStream(stream);
|
||||
}
|
||||
Config config = loadConfig(configUrl);
|
||||
if (ResourceUtils.isFileURL(configUrl)) {
|
||||
config.setConfigurationFile(configLocation.getFile());
|
||||
}
|
||||
|
@ -90,6 +87,12 @@ class HazelcastServerConfiguration {
|
|||
return config;
|
||||
}
|
||||
|
||||
private Config loadConfig(URL configUrl) throws IOException {
|
||||
try (InputStream stream = configUrl.openStream()) {
|
||||
return Config.loadFromStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
|
|
@ -76,34 +76,29 @@ public class JettyWebServerFactoryCustomizer
|
|||
|
||||
@Override
|
||||
public void customize(ConfigurableJettyWebServerFactory factory) {
|
||||
ServerProperties properties = this.serverProperties;
|
||||
ServerProperties.Jetty jettyProperties = properties.getJetty();
|
||||
ServerProperties.Jetty properties = this.serverProperties.getJetty();
|
||||
factory.setUseForwardHeaders(getOrDeduceUseForwardHeaders());
|
||||
ServerProperties.Jetty.Threads threadProperties = jettyProperties.getThreads();
|
||||
factory.setThreadPool(determineThreadPool(jettyProperties.getThreads()));
|
||||
PropertyMapper propertyMapper = PropertyMapper.get();
|
||||
propertyMapper.from(threadProperties::getAcceptors).whenNonNull().to(factory::setAcceptors);
|
||||
propertyMapper.from(threadProperties::getSelectors).whenNonNull().to(factory::setSelectors);
|
||||
propertyMapper.from(properties::getMaxHttpRequestHeaderSize)
|
||||
.whenNonNull()
|
||||
ServerProperties.Jetty.Threads threadProperties = properties.getThreads();
|
||||
factory.setThreadPool(determineThreadPool(properties.getThreads()));
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
map.from(threadProperties::getAcceptors).to(factory::setAcceptors);
|
||||
map.from(threadProperties::getSelectors).to(factory::setSelectors);
|
||||
map.from(this.serverProperties::getMaxHttpRequestHeaderSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.when(this::isPositive)
|
||||
.to((maxHttpRequestHeaderSize) -> factory
|
||||
.addServerCustomizers(new MaxHttpRequestHeaderSizeCustomizer(maxHttpRequestHeaderSize)));
|
||||
propertyMapper.from(jettyProperties::getMaxHttpResponseHeaderSize)
|
||||
.whenNonNull()
|
||||
map.from(properties::getMaxHttpResponseHeaderSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.when(this::isPositive)
|
||||
.to((maxHttpResponseHeaderSize) -> factory
|
||||
.addServerCustomizers(new MaxHttpResponseHeaderSizeCustomizer(maxHttpResponseHeaderSize)));
|
||||
propertyMapper.from(jettyProperties::getMaxHttpFormPostSize)
|
||||
map.from(properties::getMaxHttpFormPostSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.when(this::isPositive)
|
||||
.to((maxHttpFormPostSize) -> customizeMaxHttpFormPostSize(factory, maxHttpFormPostSize));
|
||||
propertyMapper.from(jettyProperties::getConnectionIdleTimeout)
|
||||
.whenNonNull()
|
||||
.to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
|
||||
propertyMapper.from(jettyProperties::getAccesslog)
|
||||
map.from(properties::getConnectionIdleTimeout).to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
|
||||
map.from(properties::getAccesslog)
|
||||
.when(ServerProperties.Jetty.Accesslog::isEnabled)
|
||||
.to((accesslog) -> customizeAccessLog(factory, accesslog));
|
||||
}
|
||||
|
@ -251,9 +246,8 @@ public class JettyWebServerFactoryCustomizer
|
|||
}
|
||||
|
||||
private void customize(ConnectionFactory factory) {
|
||||
if (factory instanceof HttpConfiguration.ConnectionFactory) {
|
||||
((HttpConfiguration.ConnectionFactory) factory).getHttpConfiguration()
|
||||
.setResponseHeaderSize(this.maxResponseHeaderSize);
|
||||
if (factory instanceof HttpConfiguration.ConnectionFactory httpConnectionFactory) {
|
||||
httpConnectionFactory.getHttpConfiguration().setResponseHeaderSize(this.maxResponseHeaderSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,17 +57,14 @@ public class NettyWebServerFactoryCustomizer
|
|||
@Override
|
||||
public void customize(NettyReactiveWebServerFactory factory) {
|
||||
factory.setUseForwardHeaders(getOrDeduceUseForwardHeaders());
|
||||
PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
ServerProperties.Netty nettyProperties = this.serverProperties.getNetty();
|
||||
propertyMapper.from(nettyProperties::getConnectionTimeout)
|
||||
.whenNonNull()
|
||||
map.from(nettyProperties::getConnectionTimeout)
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
propertyMapper.from(nettyProperties::getIdleTimeout)
|
||||
.whenNonNull()
|
||||
.to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
|
||||
propertyMapper.from(nettyProperties::getMaxKeepAliveRequests)
|
||||
map.from(nettyProperties::getIdleTimeout).to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
|
||||
map.from(nettyProperties::getMaxKeepAliveRequests)
|
||||
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
|
||||
customizeRequestDecoder(factory, propertyMapper);
|
||||
customizeRequestDecoder(factory, map);
|
||||
}
|
||||
|
||||
private boolean getOrDeduceUseForwardHeaders() {
|
||||
|
|
|
@ -83,73 +83,66 @@ public class TomcatWebServerFactoryCustomizer
|
|||
|
||||
@Override
|
||||
public void customize(ConfigurableTomcatWebServerFactory factory) {
|
||||
ServerProperties properties = this.serverProperties;
|
||||
ServerProperties.Tomcat tomcatProperties = properties.getTomcat();
|
||||
PropertyMapper propertyMapper = PropertyMapper.get();
|
||||
propertyMapper.from(tomcatProperties::getBasedir).whenNonNull().to(factory::setBaseDirectory);
|
||||
propertyMapper.from(tomcatProperties::getBackgroundProcessorDelay)
|
||||
.whenNonNull()
|
||||
ServerProperties.Tomcat properties = this.serverProperties.getTomcat();
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
map.from(properties::getBasedir).to(factory::setBaseDirectory);
|
||||
map.from(properties::getBackgroundProcessorDelay)
|
||||
.as(Duration::getSeconds)
|
||||
.as(Long::intValue)
|
||||
.to(factory::setBackgroundProcessorDelay);
|
||||
customizeRemoteIpValve(factory);
|
||||
ServerProperties.Tomcat.Threads threadProperties = tomcatProperties.getThreads();
|
||||
propertyMapper.from(threadProperties::getMax)
|
||||
ServerProperties.Tomcat.Threads threadProperties = properties.getThreads();
|
||||
map.from(threadProperties::getMax)
|
||||
.when(this::isPositive)
|
||||
.to((maxThreads) -> customizeMaxThreads(factory, threadProperties.getMax()));
|
||||
propertyMapper.from(threadProperties::getMinSpare)
|
||||
map.from(threadProperties::getMinSpare)
|
||||
.when(this::isPositive)
|
||||
.to((minSpareThreads) -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper.from(this.serverProperties.getMaxHttpRequestHeaderSize())
|
||||
.whenNonNull()
|
||||
map.from(this.serverProperties.getMaxHttpRequestHeaderSize())
|
||||
.asInt(DataSize::toBytes)
|
||||
.when(this::isPositive)
|
||||
.to((maxHttpRequestHeaderSize) -> customizeMaxHttpRequestHeaderSize(factory, maxHttpRequestHeaderSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxHttpResponseHeaderSize)
|
||||
.whenNonNull()
|
||||
map.from(properties::getMaxHttpResponseHeaderSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.when(this::isPositive)
|
||||
.to((maxHttpResponseHeaderSize) -> customizeMaxHttpResponseHeaderSize(factory, maxHttpResponseHeaderSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxSwallowSize)
|
||||
.whenNonNull()
|
||||
map.from(properties::getMaxSwallowSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.to((maxSwallowSize) -> customizeMaxSwallowSize(factory, maxSwallowSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxHttpFormPostSize)
|
||||
map.from(properties::getMaxHttpFormPostSize)
|
||||
.asInt(DataSize::toBytes)
|
||||
.when((maxHttpFormPostSize) -> maxHttpFormPostSize != 0)
|
||||
.to((maxHttpFormPostSize) -> customizeMaxHttpFormPostSize(factory, maxHttpFormPostSize));
|
||||
propertyMapper.from(tomcatProperties::getAccesslog)
|
||||
map.from(properties::getAccesslog)
|
||||
.when(ServerProperties.Tomcat.Accesslog::isEnabled)
|
||||
.to((enabled) -> customizeAccessLog(factory));
|
||||
propertyMapper.from(tomcatProperties::getUriEncoding).whenNonNull().to(factory::setUriEncoding);
|
||||
propertyMapper.from(tomcatProperties::getConnectionTimeout)
|
||||
.whenNonNull()
|
||||
map.from(properties::getUriEncoding).to(factory::setUriEncoding);
|
||||
map.from(properties::getConnectionTimeout)
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
propertyMapper.from(tomcatProperties::getMaxConnections)
|
||||
map.from(properties::getMaxConnections)
|
||||
.when(this::isPositive)
|
||||
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
|
||||
propertyMapper.from(tomcatProperties::getAcceptCount)
|
||||
map.from(properties::getAcceptCount)
|
||||
.when(this::isPositive)
|
||||
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
|
||||
propertyMapper.from(tomcatProperties::getProcessorCache)
|
||||
map.from(properties::getProcessorCache)
|
||||
.to((processorCache) -> customizeProcessorCache(factory, processorCache));
|
||||
propertyMapper.from(tomcatProperties::getKeepAliveTimeout)
|
||||
.whenNonNull()
|
||||
map.from(properties::getKeepAliveTimeout)
|
||||
.to((keepAliveTimeout) -> customizeKeepAliveTimeout(factory, keepAliveTimeout));
|
||||
propertyMapper.from(tomcatProperties::getMaxKeepAliveRequests)
|
||||
map.from(properties::getMaxKeepAliveRequests)
|
||||
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
|
||||
propertyMapper.from(tomcatProperties::getRelaxedPathChars)
|
||||
map.from(properties::getRelaxedPathChars)
|
||||
.as(this::joinCharacters)
|
||||
.whenHasText()
|
||||
.to((relaxedChars) -> customizeRelaxedPathChars(factory, relaxedChars));
|
||||
propertyMapper.from(tomcatProperties::getRelaxedQueryChars)
|
||||
map.from(properties::getRelaxedQueryChars)
|
||||
.as(this::joinCharacters)
|
||||
.whenHasText()
|
||||
.to((relaxedChars) -> customizeRelaxedQueryChars(factory, relaxedChars));
|
||||
propertyMapper.from(tomcatProperties::isRejectIllegalHeader)
|
||||
map.from(properties::isRejectIllegalHeader)
|
||||
.to((rejectIllegalHeader) -> customizeRejectIllegalHeader(factory, rejectIllegalHeader));
|
||||
customizeStaticResources(factory);
|
||||
customizeErrorReportValve(properties.getError(), factory);
|
||||
customizeErrorReportValve(this.serverProperties.getError(), factory);
|
||||
}
|
||||
|
||||
private boolean isPositive(int value) {
|
||||
|
|
|
@ -87,6 +87,7 @@ public enum CloudPlatform {
|
|||
|
||||
/**
|
||||
* Nomad platform.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
NOMAD {
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import ch.qos.logback.classic.spi.LoggerContextListener;
|
|||
import ch.qos.logback.core.ConsoleAppender;
|
||||
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
|
||||
import ch.qos.logback.core.joran.action.Action;
|
||||
import ch.qos.logback.core.joran.spi.ActionException;
|
||||
import ch.qos.logback.core.joran.spi.ElementSelector;
|
||||
import ch.qos.logback.core.joran.spi.RuleStore;
|
||||
import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
|
||||
|
@ -684,27 +685,13 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||
mock(BeanFactoryInitializationAotContribution.class));
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
beanFactory.registerSingleton("joranConfigurator1", new JoranConfigurator() {
|
||||
|
||||
@Override
|
||||
public void addElementSelectorAndActionAssociations(RuleStore ruleStore) {
|
||||
ruleStore.addRule(new ElementSelector("*/rule1"), () -> new Action() {
|
||||
@Override
|
||||
public void begin(SaxEventInterpretationContext intercon, String name, Attributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(SaxEventInterpretationContext intercon, String name) {
|
||||
}
|
||||
});
|
||||
ruleStore.addRule(new ElementSelector("*/rule2"), () -> new Action() {
|
||||
@Override
|
||||
public void begin(SaxEventInterpretationContext intercon, String name, Attributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(SaxEventInterpretationContext intercon, String name) {
|
||||
}
|
||||
});
|
||||
ruleStore.addRule(new ElementSelector("*/rule1"), () -> new EmptyAction());
|
||||
ruleStore.addRule(new ElementSelector("*/rule2"), () -> new EmptyAction());
|
||||
}
|
||||
|
||||
});
|
||||
this.loggingSystem.processAheadOfTime(beanFactory);
|
||||
this.loggingSystem.beforeInitialize();
|
||||
|
@ -755,4 +742,17 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||
.orElse(null);
|
||||
}
|
||||
|
||||
private static class EmptyAction extends Action {
|
||||
|
||||
@Override
|
||||
public void begin(SaxEventInterpretationContext intercon, String name, Attributes attributes)
|
||||
throws ActionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(SaxEventInterpretationContext intercon, String name) throws ActionException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue