@@ -83,73 +83,66 @@ public int getOrder() {
83
83
84
84
@ Override
85
85
public void customize (ConfigurableTomcatWebServerFactory factory ) {
86
- ServerProperties properties = this .serverProperties ;
87
- ServerProperties .Tomcat tomcatProperties = properties .getTomcat ();
88
- PropertyMapper propertyMapper = PropertyMapper .get ();
89
- propertyMapper .from (tomcatProperties ::getBasedir ).whenNonNull ().to (factory ::setBaseDirectory );
90
- propertyMapper .from (tomcatProperties ::getBackgroundProcessorDelay )
91
- .whenNonNull ()
86
+ ServerProperties .Tomcat properties = this .serverProperties .getTomcat ();
87
+ PropertyMapper map = PropertyMapper .get ().alwaysApplyingWhenNonNull ();
88
+ map .from (properties ::getBasedir ).to (factory ::setBaseDirectory );
89
+ map .from (properties ::getBackgroundProcessorDelay )
92
90
.as (Duration ::getSeconds )
93
91
.as (Long ::intValue )
94
92
.to (factory ::setBackgroundProcessorDelay );
95
93
customizeRemoteIpValve (factory );
96
- ServerProperties .Tomcat .Threads threadProperties = tomcatProperties .getThreads ();
97
- propertyMapper .from (threadProperties ::getMax )
94
+ ServerProperties .Tomcat .Threads threadProperties = properties .getThreads ();
95
+ map .from (threadProperties ::getMax )
98
96
.when (this ::isPositive )
99
97
.to ((maxThreads ) -> customizeMaxThreads (factory , threadProperties .getMax ()));
100
- propertyMapper .from (threadProperties ::getMinSpare )
98
+ map .from (threadProperties ::getMinSpare )
101
99
.when (this ::isPositive )
102
100
.to ((minSpareThreads ) -> customizeMinThreads (factory , minSpareThreads ));
103
- propertyMapper .from (this .serverProperties .getMaxHttpRequestHeaderSize ())
104
- .whenNonNull ()
101
+ map .from (this .serverProperties .getMaxHttpRequestHeaderSize ())
105
102
.asInt (DataSize ::toBytes )
106
103
.when (this ::isPositive )
107
104
.to ((maxHttpRequestHeaderSize ) -> customizeMaxHttpRequestHeaderSize (factory , maxHttpRequestHeaderSize ));
108
- propertyMapper .from (tomcatProperties ::getMaxHttpResponseHeaderSize )
109
- .whenNonNull ()
105
+ map .from (properties ::getMaxHttpResponseHeaderSize )
110
106
.asInt (DataSize ::toBytes )
111
107
.when (this ::isPositive )
112
108
.to ((maxHttpResponseHeaderSize ) -> customizeMaxHttpResponseHeaderSize (factory , maxHttpResponseHeaderSize ));
113
- propertyMapper .from (tomcatProperties ::getMaxSwallowSize )
114
- .whenNonNull ()
109
+ map .from (properties ::getMaxSwallowSize )
115
110
.asInt (DataSize ::toBytes )
116
111
.to ((maxSwallowSize ) -> customizeMaxSwallowSize (factory , maxSwallowSize ));
117
- propertyMapper .from (tomcatProperties ::getMaxHttpFormPostSize )
112
+ map .from (properties ::getMaxHttpFormPostSize )
118
113
.asInt (DataSize ::toBytes )
119
114
.when ((maxHttpFormPostSize ) -> maxHttpFormPostSize != 0 )
120
115
.to ((maxHttpFormPostSize ) -> customizeMaxHttpFormPostSize (factory , maxHttpFormPostSize ));
121
- propertyMapper .from (tomcatProperties ::getAccesslog )
116
+ map .from (properties ::getAccesslog )
122
117
.when (ServerProperties .Tomcat .Accesslog ::isEnabled )
123
118
.to ((enabled ) -> customizeAccessLog (factory ));
124
- propertyMapper .from (tomcatProperties ::getUriEncoding ).whenNonNull ().to (factory ::setUriEncoding );
125
- propertyMapper .from (tomcatProperties ::getConnectionTimeout )
126
- .whenNonNull ()
119
+ map .from (properties ::getUriEncoding ).to (factory ::setUriEncoding );
120
+ map .from (properties ::getConnectionTimeout )
127
121
.to ((connectionTimeout ) -> customizeConnectionTimeout (factory , connectionTimeout ));
128
- propertyMapper .from (tomcatProperties ::getMaxConnections )
122
+ map .from (properties ::getMaxConnections )
129
123
.when (this ::isPositive )
130
124
.to ((maxConnections ) -> customizeMaxConnections (factory , maxConnections ));
131
- propertyMapper .from (tomcatProperties ::getAcceptCount )
125
+ map .from (properties ::getAcceptCount )
132
126
.when (this ::isPositive )
133
127
.to ((acceptCount ) -> customizeAcceptCount (factory , acceptCount ));
134
- propertyMapper .from (tomcatProperties ::getProcessorCache )
128
+ map .from (properties ::getProcessorCache )
135
129
.to ((processorCache ) -> customizeProcessorCache (factory , processorCache ));
136
- propertyMapper .from (tomcatProperties ::getKeepAliveTimeout )
137
- .whenNonNull ()
130
+ map .from (properties ::getKeepAliveTimeout )
138
131
.to ((keepAliveTimeout ) -> customizeKeepAliveTimeout (factory , keepAliveTimeout ));
139
- propertyMapper .from (tomcatProperties ::getMaxKeepAliveRequests )
132
+ map .from (properties ::getMaxKeepAliveRequests )
140
133
.to ((maxKeepAliveRequests ) -> customizeMaxKeepAliveRequests (factory , maxKeepAliveRequests ));
141
- propertyMapper .from (tomcatProperties ::getRelaxedPathChars )
134
+ map .from (properties ::getRelaxedPathChars )
142
135
.as (this ::joinCharacters )
143
136
.whenHasText ()
144
137
.to ((relaxedChars ) -> customizeRelaxedPathChars (factory , relaxedChars ));
145
- propertyMapper .from (tomcatProperties ::getRelaxedQueryChars )
138
+ map .from (properties ::getRelaxedQueryChars )
146
139
.as (this ::joinCharacters )
147
140
.whenHasText ()
148
141
.to ((relaxedChars ) -> customizeRelaxedQueryChars (factory , relaxedChars ));
149
- propertyMapper .from (tomcatProperties ::isRejectIllegalHeader )
142
+ map .from (properties ::isRejectIllegalHeader )
150
143
.to ((rejectIllegalHeader ) -> customizeRejectIllegalHeader (factory , rejectIllegalHeader ));
151
144
customizeStaticResources (factory );
152
- customizeErrorReportValve (properties .getError (), factory );
145
+ customizeErrorReportValve (this . serverProperties .getError (), factory );
153
146
}
154
147
155
148
private boolean isPositive (int value ) {
0 commit comments