Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
34eb3695
Commit
34eb3695
authored
Apr 04, 2016
by
Quinten De Swaef
Committed by
Andy Wilkinson
Apr 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Tomcat's minimum threads to be configured via the environment
Closes gh-5572
parent
ca716561
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+32
-0
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+8
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
34eb3695
...
@@ -580,6 +580,11 @@ public class ServerProperties
...
@@ -580,6 +580,11 @@ public class ServerProperties
*/
*/
private
int
maxThreads
=
0
;
// Number of threads in protocol handler
private
int
maxThreads
=
0
;
// Number of threads in protocol handler
/**
* Minimum amount of worker threads.
*/
private
int
minSpareThreads
=
0
;
//Number of minimum spare threads in protocol handler
/**
/**
* Maximum size in bytes of the HTTP message header.
* Maximum size in bytes of the HTTP message header.
*/
*/
...
@@ -598,6 +603,14 @@ public class ServerProperties
...
@@ -598,6 +603,14 @@ public class ServerProperties
this
.
maxThreads
=
maxThreads
;
this
.
maxThreads
=
maxThreads
;
}
}
public
int
getMinSpareThreads
()
{
return
minSpareThreads
;
}
public
void
setMinSpareThreads
(
int
minSpareThreads
)
{
this
.
minSpareThreads
=
minSpareThreads
;
}
public
int
getMaxHttpHeaderSize
()
{
public
int
getMaxHttpHeaderSize
()
{
return
this
.
maxHttpHeaderSize
;
return
this
.
maxHttpHeaderSize
;
}
}
...
@@ -684,6 +697,9 @@ public class ServerProperties
...
@@ -684,6 +697,9 @@ public class ServerProperties
if
(
this
.
maxThreads
>
0
)
{
if
(
this
.
maxThreads
>
0
)
{
customizeMaxThreads
(
factory
);
customizeMaxThreads
(
factory
);
}
}
if
(
this
.
minSpareThreads
>
0
)
{
customizeMinThreads
(
factory
);
}
if
(
this
.
maxHttpHeaderSize
>
0
)
{
if
(
this
.
maxHttpHeaderSize
>
0
)
{
customizeMaxHttpHeaderSize
(
factory
);
customizeMaxHttpHeaderSize
(
factory
);
}
}
...
@@ -747,6 +763,22 @@ public class ServerProperties
...
@@ -747,6 +763,22 @@ public class ServerProperties
});
});
}
}
@SuppressWarnings
(
"rawtypes"
)
private
void
customizeMinThreads
(
TomcatEmbeddedServletContainerFactory
factory
)
{
factory
.
addConnectorCustomizers
(
new
TomcatConnectorCustomizer
()
{
@Override
public
void
customize
(
Connector
connector
)
{
ProtocolHandler
handler
=
connector
.
getProtocolHandler
();
if
(
handler
instanceof
AbstractProtocol
)
{
AbstractProtocol
protocol
=
(
AbstractProtocol
)
handler
;
protocol
.
setMinSpareThreads
(
Tomcat
.
this
.
minSpareThreads
);
}
}
});
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
private
void
customizeMaxHttpHeaderSize
(
private
void
customizeMaxHttpHeaderSize
(
TomcatEmbeddedServletContainerFactory
factory
)
{
TomcatEmbeddedServletContainerFactory
factory
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
34eb3695
...
@@ -258,6 +258,14 @@ public class ServerPropertiesTests {
...
@@ -258,6 +258,14 @@ public class ServerPropertiesTests {
assertThat
(
this
.
properties
.
getTomcat
().
getMaxHttpHeaderSize
()).
isEqualTo
(
9999
);
assertThat
(
this
.
properties
.
getTomcat
().
getMaxHttpHeaderSize
()).
isEqualTo
(
9999
);
}
}
@Test
public
void
testCustomizeTomcatMinSpareThreads
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.tomcat.min-spare-threads"
,
"10"
);
bindProperties
(
map
);
assertThat
(
this
.
properties
.
getTomcat
().
getMinSpareThreads
()).
isEqualTo
(
10
);
}
@Test
@Test
public
void
customizeTomcatDisplayName
()
throws
Exception
{
public
void
customizeTomcatDisplayName
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
34eb3695
...
@@ -204,6 +204,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -204,6 +204,7 @@ content into your application; rather pick only the properties that you need.
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.tomcat.max-threads=0 # Maximum amount of worker threads.
server.tomcat.max-threads=0 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=0 # Maximum amount of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL.
server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment