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
c9f9246c
Commit
c9f9246c
authored
Jan 06, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-24657
parents
ab808035
78259214
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
24 deletions
+53
-24
JettyWebServer.java
...ringframework/boot/web/embedded/jetty/JettyWebServer.java
+24
-15
NettyWebServer.java
...ringframework/boot/web/embedded/netty/NettyWebServer.java
+2
-2
TomcatWebServer.java
...ngframework/boot/web/embedded/tomcat/TomcatWebServer.java
+2
-2
UndertowWebServer.java
...amework/boot/web/embedded/undertow/UndertowWebServer.java
+2
-2
AbstractReactiveWebServerFactoryTests.java
...eactive/server/AbstractReactiveWebServerFactoryTests.java
+11
-1
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+12
-2
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -207,18 +207,6 @@ public class JettyWebServer implements WebServer {
...
@@ -207,18 +207,6 @@ public class JettyWebServer implements WebServer {
return
ports
.
toString
();
return
ports
.
toString
();
}
}
private
Integer
getLocalPort
(
Connector
connector
)
{
try
{
// Jetty 9 internals are different, but the method name is the same
return
(
Integer
)
ReflectionUtils
.
invokeMethod
(
ReflectionUtils
.
findMethod
(
connector
.
getClass
(),
"getLocalPort"
),
connector
);
}
catch
(
Exception
ex
)
{
logger
.
info
(
"could not determine port ( "
+
ex
.
getMessage
()
+
")"
);
return
0
;
}
}
private
String
getProtocols
(
Connector
connector
)
{
private
String
getProtocols
(
Connector
connector
)
{
List
<
String
>
protocols
=
connector
.
getProtocols
();
List
<
String
>
protocols
=
connector
.
getProtocols
();
return
" ("
+
StringUtils
.
collectionToDelimitedString
(
protocols
,
", "
)
+
")"
;
return
" ("
+
StringUtils
.
collectionToDelimitedString
(
protocols
,
", "
)
+
")"
;
...
@@ -276,8 +264,29 @@ public class JettyWebServer implements WebServer {
...
@@ -276,8 +264,29 @@ public class JettyWebServer implements WebServer {
public
int
getPort
()
{
public
int
getPort
()
{
Connector
[]
connectors
=
this
.
server
.
getConnectors
();
Connector
[]
connectors
=
this
.
server
.
getConnectors
();
for
(
Connector
connector
:
connectors
)
{
for
(
Connector
connector
:
connectors
)
{
// Probably only one...
Integer
localPort
=
getLocalPort
(
connector
);
return
getLocalPort
(
connector
);
if
(
localPort
!=
null
&&
localPort
>
0
)
{
return
localPort
;
}
}
return
-
1
;
}
private
Integer
getLocalPort
(
Connector
connector
)
{
try
{
if
(
connector
instanceof
NetworkConnector
)
{
return
((
NetworkConnector
)
connector
).
getLocalPort
();
}
}
catch
(
Exception
ex
)
{
}
try
{
// Jetty 9 internals are different, but the method name is the same
return
(
Integer
)
ReflectionUtils
.
invokeMethod
(
ReflectionUtils
.
findMethod
(
connector
.
getClass
(),
"getLocalPort"
),
connector
);
}
catch
(
Exception
ex
)
{
logger
.
info
(
"could not determine port ( "
+
ex
.
getMessage
()
+
")"
);
}
}
return
0
;
return
0
;
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -217,7 +217,7 @@ public class NettyWebServer implements WebServer {
...
@@ -217,7 +217,7 @@ public class NettyWebServer implements WebServer {
return
-
1
;
return
-
1
;
}
}
}
}
return
0
;
return
-
1
;
}
}
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -364,7 +364,7 @@ public class TomcatWebServer implements WebServer {
...
@@ -364,7 +364,7 @@ public class TomcatWebServer implements WebServer {
if
(
connector
!=
null
)
{
if
(
connector
!=
null
)
{
return
connector
.
getLocalPort
();
return
connector
.
getLocalPort
();
}
}
return
0
;
return
-
1
;
}
}
private
String
getContextPath
()
{
private
String
getContextPath
()
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -295,7 +295,7 @@ public class UndertowWebServer implements WebServer {
...
@@ -295,7 +295,7 @@ public class UndertowWebServer implements WebServer {
public
int
getPort
()
{
public
int
getPort
()
{
List
<
Port
>
ports
=
getActualPorts
();
List
<
Port
>
ports
=
getActualPorts
();
if
(
ports
.
isEmpty
())
{
if
(
ports
.
isEmpty
())
{
return
0
;
return
-
1
;
}
}
return
ports
.
get
(
0
).
getNumber
();
return
ports
.
get
(
0
).
getNumber
();
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -115,6 +115,16 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -115,6 +115,16 @@ public abstract class AbstractReactiveWebServerFactoryTests {
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(
specificPort
);
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(
specificPort
);
}
}
@Test
void
portIsMinusOneWhenConnectionIsClosed
()
{
AbstractReactiveWebServerFactory
factory
=
getFactory
();
this
.
webServer
=
factory
.
getWebServer
(
new
EchoHandler
());
this
.
webServer
.
start
();
assertThat
(
this
.
webServer
.
getPort
()).
isGreaterThan
(
0
);
this
.
webServer
.
stop
();
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(-
1
);
}
@Test
@Test
void
basicSslFromClassPath
()
{
void
basicSslFromClassPath
()
{
testBasicSslWithKeyStore
(
"classpath:test.jks"
,
"password"
);
testBasicSslWithKeyStore
(
"classpath:test.jks"
,
"password"
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
c9f9246c
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -250,7 +250,7 @@ public abstract class AbstractServletWebServerFactoryTests {
...
@@ -250,7 +250,7 @@ public abstract class AbstractServletWebServerFactoryTests {
factory
.
setPort
(-
1
);
factory
.
setPort
(-
1
);
this
.
webServer
=
factory
.
getWebServer
(
exampleServletRegistration
());
this
.
webServer
=
factory
.
getWebServer
(
exampleServletRegistration
());
this
.
webServer
.
start
();
this
.
webServer
.
start
();
assertThat
(
this
.
webServer
.
getPort
()).
is
LessThan
(
0
);
// Jetty is -2
assertThat
(
this
.
webServer
.
getPort
()).
is
EqualTo
(-
1
);
}
}
@Test
@Test
...
@@ -300,6 +300,16 @@ public abstract class AbstractServletWebServerFactoryTests {
...
@@ -300,6 +300,16 @@ public abstract class AbstractServletWebServerFactoryTests {
assertThat
(
servlet
.
getInitCount
()).
isEqualTo
(
1
);
assertThat
(
servlet
.
getInitCount
()).
isEqualTo
(
1
);
}
}
@Test
void
portIsMinusOneWhenConnectionIsClosed
()
{
AbstractServletWebServerFactory
factory
=
getFactory
();
this
.
webServer
=
factory
.
getWebServer
();
this
.
webServer
.
start
();
assertThat
(
this
.
webServer
.
getPort
()).
isGreaterThan
(
0
);
this
.
webServer
.
stop
();
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(-
1
);
}
@Test
@Test
void
specificPort
()
throws
Exception
{
void
specificPort
()
throws
Exception
{
AbstractServletWebServerFactory
factory
=
getFactory
();
AbstractServletWebServerFactory
factory
=
getFactory
();
...
...
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