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
bc47bf44
Commit
bc47bf44
authored
Jun 01, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
81ef6fec
152ce145
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
47 deletions
+42
-47
README.adoc
README.adoc
+1
-1
JestAutoConfiguration.java
...toconfigure/elasticsearch/jest/JestAutoConfiguration.java
+1
-1
Restarter.java
.../org/springframework/boot/devtools/restart/Restarter.java
+12
-7
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
getting-started.adoc
...t/spring-boot-docs/src/main/asciidoc/getting-started.adoc
+1
-1
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+3
-3
StringSequence.java
...a/org/springframework/boot/loader/jar/StringSequence.java
+3
-3
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+9
-6
SampleTomcatDeployApplicationIT.java
...src/test/java/sample/SampleTomcatDeployApplicationIT.java
+11
-24
No files found.
README.adoc
View file @
bc47bf44
...
@@ -224,7 +224,7 @@ This module contains core items and annotations that can be helpful when testing
...
@@ -224,7 +224,7 @@ This module contains core items and annotations that can be helpful when testing
=== spring-boot-test-autoconfigure
=== spring-boot-test-autoconfigure
Like other Spring Boot
Auto-C
onfiguration modules, spring-boot-test-autoconfigure, provides auto-configuration
Like other Spring Boot
auto-c
onfiguration modules, spring-boot-test-autoconfigure, provides auto-configuration
for tests based on the classpath. It includes a number of annotations that can be used to automatically
for tests based on the classpath. It includes a number of annotations that can be used to automatically
configure a slice of your application that needs to be tested.
configure a slice of your application that needs to be tested.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java
View file @
bc47bf44
...
@@ -39,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -39,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
/**
/**
* {@link EnableAutoConfiguration Auto-
C
onfiguration} for Jest.
* {@link EnableAutoConfiguration Auto-
c
onfiguration} for Jest.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.4.0
* @since 1.4.0
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java
View file @
bc47bf44
...
@@ -134,7 +134,9 @@ public class Restarter {
...
@@ -134,7 +134,9 @@ public class Restarter {
Assert
.
notNull
(
thread
,
"Thread must not be null"
);
Assert
.
notNull
(
thread
,
"Thread must not be null"
);
Assert
.
notNull
(
args
,
"Args must not be null"
);
Assert
.
notNull
(
args
,
"Args must not be null"
);
Assert
.
notNull
(
initializer
,
"Initializer must not be null"
);
Assert
.
notNull
(
initializer
,
"Initializer must not be null"
);
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Creating new Restarter for thread "
+
thread
);
this
.
logger
.
debug
(
"Creating new Restarter for thread "
+
thread
);
}
SilentExitExceptionHandler
.
setup
(
thread
);
SilentExitExceptionHandler
.
setup
(
thread
);
this
.
forceReferenceCleanup
=
forceReferenceCleanup
;
this
.
forceReferenceCleanup
=
forceReferenceCleanup
;
this
.
initialUrls
=
initializer
.
getInitialUrls
(
thread
);
this
.
initialUrls
=
initializer
.
getInitialUrls
(
thread
);
...
@@ -360,7 +362,10 @@ public class Restarter {
...
@@ -360,7 +362,10 @@ public class Restarter {
clear
(
Class
.
forName
(
className
),
fieldName
);
clear
(
Class
.
forName
(
className
),
fieldName
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
this
.
logger
.
debug
(
"Unable to clear field "
+
className
+
" "
+
fieldName
,
ex
);
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Unable to clear field "
+
className
+
" "
+
fieldName
,
ex
);
}
}
}
}
}
...
@@ -377,15 +382,15 @@ public class Restarter {
...
@@ -377,15 +382,15 @@ public class Restarter {
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Unable to clear field "
+
type
+
" "
+
fieldName
,
ex
);
this
.
logger
.
debug
(
"Unable to clear field "
+
type
+
" "
+
fieldName
,
ex
);
}
}
}
}
}
private
boolean
isFromRestartClassLoader
(
Object
object
)
{
private
boolean
isFromRestartClassLoader
(
Object
object
)
{
if
(
object
instanceof
Class
)
{
return
(
object
instanceof
Class
return
((
Class
<?>)
object
).
getClassLoader
()
instanceof
RestartClassLoader
;
&&
((
Class
<?>)
object
).
getClassLoader
()
instanceof
RestartClassLoader
);
}
return
false
;
}
}
/**
/**
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
bc47bf44
spring-boot-project/spring-boot-docs/src/main/asciidoc/getting-started.adoc
View file @
bc47bf44
...
@@ -662,7 +662,7 @@ that you have added. Since `spring-boot-starter-web` added Tomcat and Spring MVC
...
@@ -662,7 +662,7 @@ that you have added. Since `spring-boot-starter-web` added Tomcat and Spring MVC
auto-configuration assumes that you are developing a web application and sets up Spring
auto-configuration assumes that you are developing a web application and sets up Spring
accordingly.
accordingly.
.Starters and Auto-
C
onfiguration
.Starters and Auto-
c
onfiguration
****
****
Auto-configuration is designed to work well with "`Starters`", but the two concepts are
Auto-configuration is designed to work well with "`Starters`", but the two concepts are
not directly tied. You are free to pick and choose jar dependencies outside of the
not directly tied. You are free to pick and choose jar dependencies outside of the
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
bc47bf44
...
@@ -2064,7 +2064,7 @@ directory locations). The root Servlet context path, `"/"`, is automatically add
...
@@ -2064,7 +2064,7 @@ directory locations). The root Servlet context path, `"/"`, is automatically add
location as well.
location as well.
In addition to the "`standard`" static resource locations mentioned earlier, a special
In addition to the "`standard`" static resource locations mentioned earlier, a special
case is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
case is made for http
s
://www.webjars.org/[Webjars content]. Any resources with a path in
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
TIP: Do not use the `src/main/webapp` directory if your application is packaged as a jar.
TIP: Do not use the `src/main/webapp` directory if your application is packaged as a jar.
...
@@ -2625,7 +2625,7 @@ custom locations. So, if there is an `index.html` in any of your locations on st
...
@@ -2625,7 +2625,7 @@ custom locations. So, if there is an `index.html` in any of your locations on st
is the home page of the application.
is the home page of the application.
In addition to the "`standard`" static resource locations listed earlier, a special case
In addition to the "`standard`" static resource locations listed earlier, a special case
is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
is made for http
s
://www.webjars.org/[Webjars content]. Any resources with a path in
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
TIP: Spring WebFlux applications do not strictly depend on the Servlet API, so they
TIP: Spring WebFlux applications do not strictly depend on the Servlet API, so they
...
@@ -7259,7 +7259,7 @@ which auto-configures one for you.
...
@@ -7259,7 +7259,7 @@ which auto-configures one for you.
[[boot-features-
environment-test-utiliti
es]]
[[boot-features-
test-property-valu
es]]
==== TestPropertyValues
==== TestPropertyValues
`TestPropertyValues` lets you quickly add properties to a
`TestPropertyValues` lets you quickly add properties to a
`ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with
`ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java
View file @
bc47bf44
...
@@ -99,11 +99,11 @@ final class StringSequence implements CharSequence {
...
@@ -99,11 +99,11 @@ final class StringSequence implements CharSequence {
return
startsWith
(
prefix
,
0
);
return
startsWith
(
prefix
,
0
);
}
}
public
boolean
startsWith
(
CharSequence
prefix
,
int
t
offset
)
{
public
boolean
startsWith
(
CharSequence
prefix
,
int
offset
)
{
if
(
length
()
-
prefix
.
length
()
-
t
offset
<
0
)
{
if
(
length
()
-
prefix
.
length
()
-
offset
<
0
)
{
return
false
;
return
false
;
}
}
return
subSequence
(
toffset
,
t
offset
+
prefix
.
length
()).
equals
(
prefix
);
return
subSequence
(
offset
,
offset
+
prefix
.
length
()).
equals
(
prefix
);
}
}
@Override
@Override
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
bc47bf44
...
@@ -20,6 +20,7 @@ import java.io.IOException;
...
@@ -20,6 +20,7 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Deque
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
...
@@ -301,7 +302,7 @@ public class ConfigFileApplicationListener
...
@@ -301,7 +302,7 @@ public class ConfigFileApplicationListener
private
final
List
<
PropertySourceLoader
>
propertySourceLoaders
;
private
final
List
<
PropertySourceLoader
>
propertySourceLoaders
;
private
LinkedList
<
Profile
>
profiles
;
private
Deque
<
Profile
>
profiles
;
private
List
<
Profile
>
processedProfiles
;
private
List
<
Profile
>
processedProfiles
;
...
@@ -345,9 +346,9 @@ public class ConfigFileApplicationListener
...
@@ -345,9 +346,9 @@ public class ConfigFileApplicationListener
// The default profile for these purposes is represented as null. We add it
// The default profile for these purposes is represented as null. We add it
// first so that it is processed first and has lowest priority.
// first so that it is processed first and has lowest priority.
this
.
profiles
.
add
(
null
);
this
.
profiles
.
add
(
null
);
Set
<
Profile
>
activatedViaProperty
=
getProfilesActivatedVia
ActiveProfile
Property
();
Set
<
Profile
>
activatedViaProperty
=
getProfilesActivatedViaProperty
();
processOtherActiveProfiles
(
activatedViaProperty
);
processOtherActiveProfiles
(
activatedViaProperty
);
// Any pre-existing active
activeP
rofiles set via property sources (e.g.
// Any pre-existing active
p
rofiles set via property sources (e.g.
// System
// System
// properties) take precedence over those added in config files.
// properties) take precedence over those added in config files.
addActiveProfiles
(
activatedViaProperty
);
addActiveProfiles
(
activatedViaProperty
);
...
@@ -360,7 +361,7 @@ public class ConfigFileApplicationListener
...
@@ -360,7 +361,7 @@ public class ConfigFileApplicationListener
}
}
}
}
private
Set
<
Profile
>
getProfilesActivatedVia
ActiveProfile
Property
()
{
private
Set
<
Profile
>
getProfilesActivatedViaProperty
()
{
if
(!
this
.
environment
.
containsProperty
(
ACTIVE_PROFILES_PROPERTY
)
if
(!
this
.
environment
.
containsProperty
(
ACTIVE_PROFILES_PROPERTY
)
&&
!
this
.
environment
.
containsProperty
(
INCLUDE_PROFILES_PROPERTY
))
{
&&
!
this
.
environment
.
containsProperty
(
INCLUDE_PROFILES_PROPERTY
))
{
return
Collections
.
emptySet
();
return
Collections
.
emptySet
();
...
@@ -385,8 +386,10 @@ public class ConfigFileApplicationListener
...
@@ -385,8 +386,10 @@ public class ConfigFileApplicationListener
return
;
return
;
}
}
addProfiles
(
profiles
);
addProfiles
(
profiles
);
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Activated activeProfiles "
this
.
logger
.
debug
(
"Activated activeProfiles "
+
StringUtils
.
collectionToCommaDelimitedString
(
profiles
));
+
StringUtils
.
collectionToCommaDelimitedString
(
profiles
));
}
this
.
activatedProfiles
=
true
;
this
.
activatedProfiles
=
true
;
removeUnprocessedDefaultProfiles
();
removeUnprocessedDefaultProfiles
();
}
}
...
...
spring-boot-tests/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/test/java/sample/SampleTomcatDeployApplicationIT.java
View file @
bc47bf44
...
@@ -58,62 +58,49 @@ public class SampleTomcatDeployApplicationIT {
...
@@ -58,62 +58,49 @@ public class SampleTomcatDeployApplicationIT {
@Test
@Test
public
void
errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse
()
public
void
errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse
()
throws
Exception
{
throws
Exception
{
assertThat
ErrorFromExceptionProducesExpectedResponse
(
MediaType
.
ALL
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/exception"
,
MediaType
.
ALL
,
MediaType
.
APPLICATION_JSON
);
MediaType
.
APPLICATION_JSON
);
}
}
@Test
@Test
public
void
errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse
()
public
void
errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse
()
throws
Exception
{
throws
Exception
{
assertThat
ErrorFromExceptionProducesExpectedResponse
(
MediaType
.
APPLICATION_JSON
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/exception"
,
MediaType
.
APPLICATION_JSON
);
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_JSON
);
}
}
@Test
@Test
public
void
errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse
()
public
void
errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse
()
throws
Exception
{
throws
Exception
{
assertThat
ErrorFromExceptionProducesExpectedResponse
(
MediaType
.
TEXT_HTML
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/exception"
,
MediaType
.
TEXT_HTML
,
MediaType
.
TEXT_HTML
);
MediaType
.
TEXT_HTML
);
}
}
@Test
@Test
public
void
sendErrorForRequestAcceptingAnythingProducesAJsonResponse
()
public
void
sendErrorForRequestAcceptingAnythingProducesAJsonResponse
()
throws
Exception
{
throws
Exception
{
assertThat
SendErrorProducesExpectedResponse
(
MediaType
.
ALL
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/send-error"
,
MediaType
.
ALL
,
MediaType
.
APPLICATION_JSON
);
MediaType
.
APPLICATION_JSON
);
}
}
@Test
@Test
public
void
sendErrorForRequestAcceptingJsonProducesAJsonResponse
()
throws
Exception
{
public
void
sendErrorForRequestAcceptingJsonProducesAJsonResponse
()
throws
Exception
{
assertThat
SendErrorProducesExpectedResponse
(
MediaType
.
APPLICATION_JSON
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/send-error"
,
MediaType
.
APPLICATION_JSON
);
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_JSON
);
}
}
@Test
@Test
public
void
sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse
()
public
void
sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse
()
throws
Exception
{
throws
Exception
{
assertThat
SendErrorProducesExpectedResponse
(
MediaType
.
TEXT_HTML
,
assertThat
PathProducesExpectedResponse
(
"/bootapp/send-error"
,
MediaType
.
TEXT_HTML
,
MediaType
.
TEXT_HTML
);
MediaType
.
TEXT_HTML
);
}
}
private
void
assertThatSendErrorProducesExpectedResponse
(
MediaType
accept
,
private
void
assertThatPathProducesExpectedResponse
(
String
path
,
MediaType
accept
,
MediaType
contentType
)
{
RequestEntity
<
Void
>
request
=
RequestEntity
.
get
(
URI
.
create
(
"http://localhost:"
+
this
.
port
+
"/bootapp/send-error"
))
.
accept
(
accept
).
build
();
ResponseEntity
<
String
>
response
=
this
.
rest
.
exchange
(
request
,
String
.
class
);
assertThat
(
response
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
assertThat
(
contentType
.
isCompatibleWith
(
response
.
getHeaders
().
getContentType
()))
.
as
(
"%s is compatible with %s"
,
contentType
,
response
.
getHeaders
().
getContentType
())
.
isTrue
();
}
private
void
assertThatErrorFromExceptionProducesExpectedResponse
(
MediaType
accept
,
MediaType
contentType
)
{
MediaType
contentType
)
{
RequestEntity
<
Void
>
request
=
RequestEntity
RequestEntity
<
Void
>
request
=
RequestEntity
.
get
(
URI
.
create
(
"http://localhost:"
+
this
.
port
+
"/bootapp/exception"
)
)
.
get
(
URI
.
create
(
"http://localhost:"
+
this
.
port
+
path
)).
accept
(
accept
)
.
accept
(
accept
).
build
();
.
build
();
ResponseEntity
<
String
>
response
=
this
.
rest
.
exchange
(
request
,
String
.
class
);
ResponseEntity
<
String
>
response
=
this
.
rest
.
exchange
(
request
,
String
.
class
);
assertThat
(
response
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
assertThat
(
response
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
assertThat
(
contentType
.
isCompatibleWith
(
response
.
getHeaders
().
getContentType
()))
assertThat
(
contentType
.
isCompatibleWith
(
response
.
getHeaders
().
getContentType
()))
...
...
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