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
3bd7760f
Commit
3bd7760f
authored
Jul 04, 2019
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Allow Undertow's options to be configured via the environment
See gh-17356
parent
417f4dd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
UndertowWebServerFactoryCustomizer.java
...gure/web/embedded/UndertowWebServerFactoryCustomizer.java
+5
-5
UndertowWebServerFactoryCustomizerTests.java
...web/embedded/UndertowWebServerFactoryCustomizerTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java
View file @
3bd7760f
...
...
@@ -142,12 +142,12 @@ public class UndertowWebServerFactoryCustomizer
return
this
.
serverProperties
.
getForwardHeadersStrategy
().
equals
(
ServerProperties
.
ForwardHeadersStrategy
.
NATIVE
);
}
@SuppressWarnings
(
"unchecked"
)
private
<
T
>
void
setCustomOption
(
ConfigurableUndertowWebServerFactory
factory
,
String
key
,
String
value
,
String
type
)
{
Field
[]
fields
=
UndertowOptions
.
class
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
String
name
=
getLetterAndNumber
(
key
);
if
(
getLetterAndNumber
(
field
.
getName
()).
equals
(
name
))
{
if
(
getCanonicalName
(
field
.
getName
()).
equals
(
getCanonicalName
(
key
)))
{
Option
<
T
>
option
=
(
Option
<
T
>)
Option
.
fromString
(
UndertowOptions
.
class
.
getName
()
+
'.'
+
field
.
getName
(),
getClass
().
getClassLoader
());
T
parsed
=
option
.
parseValue
(
value
,
getClass
().
getClassLoader
());
...
...
@@ -162,9 +162,9 @@ public class UndertowWebServerFactoryCustomizer
}
}
private
String
get
LetterAndNumber
(
String
name
)
{
StringBuilder
canonicalName
=
new
StringBuilder
(
name
.
length
());
name
.
chars
().
map
((
c
)
->
(
char
)
c
).
filter
(
Character:
:
isLetterOrDigit
).
map
(
Character:
:
toLowerCase
)
private
String
get
CanonicalName
(
String
key
)
{
StringBuilder
canonicalName
=
new
StringBuilder
(
key
.
length
());
key
.
chars
().
map
((
c
)
->
(
char
)
c
).
filter
(
Character:
:
isLetterOrDigit
).
map
(
Character:
:
toLowerCase
)
.
forEach
((
c
)
->
canonicalName
.
append
((
char
)
c
));
return
canonicalName
.
toString
();
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java
View file @
3bd7760f
...
...
@@ -161,12 +161,23 @@ class UndertowWebServerFactoryCustomizerTests {
assertThat
(
boundServerOption
(
UndertowOptions
.
ALWAYS_SET_KEEP_ALIVE
)).
isFalse
();
}
@Test
void
customServerOptionShouldBeRelaxed
()
{
bind
(
"server.undertow.options.server.always-set-keep-alive=false"
);
assertThat
(
boundServerOption
(
UndertowOptions
.
ALWAYS_SET_KEEP_ALIVE
)).
isFalse
();
}
@Test
void
customSocketOption
()
{
bind
(
"server.undertow.options.socket.ALWAYS_SET_KEEP_ALIVE=false"
);
assertThat
(
boundSocketOption
(
UndertowOptions
.
ALWAYS_SET_KEEP_ALIVE
)).
isFalse
();
}
void
customSocketOptionShouldBeRelaxed
()
{
bind
(
"server.undertow.options.socket.always-set-keep-alive=false"
);
assertThat
(
boundSocketOption
(
UndertowOptions
.
ALWAYS_SET_KEEP_ALIVE
)).
isFalse
();
}
@Test
void
deduceUseForwardHeaders
()
{
this
.
environment
.
setProperty
(
"DYNO"
,
"-"
);
...
...
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