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
e1819823
Commit
e1819823
authored
Aug 03, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22699 from dreis2211
* pr/22699: Use Supplier variants of Assert methods Closes gh-22699
parents
bb3066f6
e49e2dff
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
32 additions
and
28 deletions
+32
-28
AutoConfigurationSorter.java
...framework/boot/autoconfigure/AutoConfigurationSorter.java
+7
-3
Saml2RelyingPartyRegistrationConfiguration.java
...ity/saml2/Saml2RelyingPartyRegistrationConfiguration.java
+2
-2
AbstractTemplateViewResolverProperties.java
...gure/template/AbstractTemplateViewResolverProperties.java
+2
-2
UndertowWebServerFactoryCustomizer.java
...gure/web/embedded/UndertowWebServerFactoryCustomizer.java
+1
-1
Builder.java
...pringframework/boot/buildpack/platform/build/Builder.java
+2
-2
JarModeLibrary.java
...org/springframework/boot/loader/tools/JarModeLibrary.java
+1
-1
Packager.java
.../java/org/springframework/boot/loader/tools/Packager.java
+1
-1
CustomLayers.java
...springframework/boot/loader/tools/layer/CustomLayers.java
+1
-1
LayersIndexTests.java
...g/springframework/boot/loader/tools/LayersIndexTests.java
+1
-1
ConfigDataLoaders.java
...pringframework/boot/context/config/ConfigDataLoaders.java
+1
-1
DelegatingApplicationContextInitializer.java
...ntext/config/DelegatingApplicationContextInitializer.java
+2
-2
DelegatingApplicationListener.java
...rk/boot/context/config/DelegatingApplicationListener.java
+2
-2
ConfigurationPropertiesBean.java
.../boot/context/properties/ConfigurationPropertiesBean.java
+2
-2
ConfigurationPropertiesBindConstructorProvider.java
...rties/ConfigurationPropertiesBindConstructorProvider.java
+3
-3
PeriodStyle.java
...in/java/org/springframework/boot/convert/PeriodStyle.java
+1
-1
VolumeMountDirectoryPropertySource.java
...ramework/boot/env/VolumeMountDirectoryPropertySource.java
+2
-2
LogbackLoggingSystem.java
...gframework/boot/logging/logback/LogbackLoggingSystem.java
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -88,8 +88,7 @@ class AutoConfigurationSorter {
}
processing
.
add
(
current
);
for
(
String
after
:
classes
.
getClassesRequestedAfter
(
current
))
{
Assert
.
state
(!
processing
.
contains
(
after
),
"AutoConfigure cycle detected between "
+
current
+
" and "
+
after
);
checkForCycles
(
processing
,
current
,
after
);
if
(!
sorted
.
contains
(
after
)
&&
toSort
.
contains
(
after
))
{
doSortByAfterAnnotation
(
classes
,
toSort
,
sorted
,
processing
,
after
);
}
...
...
@@ -98,6 +97,11 @@ class AutoConfigurationSorter {
sorted
.
add
(
current
);
}
private
void
checkForCycles
(
Set
<
String
>
processing
,
String
current
,
String
after
)
{
Assert
.
state
(!
processing
.
contains
(
after
),
()
->
"AutoConfigure cycle detected between "
+
current
+
" and "
+
after
);
}
private
static
class
AutoConfigurationClasses
{
private
final
Map
<
String
,
AutoConfigurationClass
>
classes
=
new
HashMap
<>();
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java
View file @
e1819823
...
...
@@ -111,7 +111,7 @@ class Saml2RelyingPartyRegistrationConfiguration {
private
RSAPrivateKey
readPrivateKey
(
Resource
location
)
{
Assert
.
state
(
location
!=
null
,
"No private key location specified"
);
Assert
.
state
(
location
.
exists
(),
"Private key location '"
+
location
+
"' does not exist"
);
Assert
.
state
(
location
.
exists
(),
()
->
"Private key location '"
+
location
+
"' does not exist"
);
try
(
InputStream
inputStream
=
location
.
getInputStream
())
{
return
RsaKeyConverters
.
pkcs8
().
convert
(
inputStream
);
}
...
...
@@ -122,7 +122,7 @@ class Saml2RelyingPartyRegistrationConfiguration {
private
X509Certificate
readCertificate
(
Resource
location
)
{
Assert
.
state
(
location
!=
null
,
"No certificate location specified"
);
Assert
.
state
(
location
.
exists
(),
"Certificate location '"
+
location
+
"' does not exist"
);
Assert
.
state
(
location
.
exists
(),
()
->
"Certificate location '"
+
location
+
"' does not exist"
);
try
(
InputStream
inputStream
=
location
.
getInputStream
())
{
return
(
X509Certificate
)
CertificateFactory
.
getInstance
(
"X.509"
).
generateCertificate
(
inputStream
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -152,7 +152,7 @@ public abstract class AbstractTemplateViewResolverProperties extends AbstractVie
*/
public
void
applyToMvcViewResolver
(
Object
viewResolver
)
{
Assert
.
isInstanceOf
(
AbstractTemplateViewResolver
.
class
,
viewResolver
,
"ViewResolver is not an instance of AbstractTemplateViewResolver :"
+
viewResolver
);
()
->
"ViewResolver is not an instance of AbstractTemplateViewResolver :"
+
viewResolver
);
AbstractTemplateViewResolver
resolver
=
(
AbstractTemplateViewResolver
)
viewResolver
;
resolver
.
setPrefix
(
getPrefix
());
resolver
.
setSuffix
(
getSuffix
());
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java
View file @
e1819823
...
...
@@ -168,7 +168,7 @@ public class UndertowWebServerFactoryCustomizer
return
(
map
)
->
map
.
forEach
((
key
,
value
)
->
{
Option
<
T
>
option
=
(
Option
<
T
>)
this
.
nameLookup
.
get
(
getCanonicalName
(
key
));
Assert
.
state
(
option
!=
null
,
"Unable to find '"
+
key
+
"' in "
+
ClassUtils
.
getShortClassName
(
this
.
source
));
()
->
"Unable to find '"
+
key
+
"' in "
+
ClassUtils
.
getShortClassName
(
this
.
source
));
T
parsed
=
option
.
parseValue
(
value
,
getClass
().
getClassLoader
());
function
.
apply
(
option
).
accept
(
parsed
);
});
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java
View file @
e1819823
...
...
@@ -113,8 +113,8 @@ public class Builder {
private
void
assertStackIdsMatch
(
Image
runImage
,
Image
builderImage
)
{
StackId
runImageStackId
=
StackId
.
fromImage
(
runImage
);
StackId
builderImageStackId
=
StackId
.
fromImage
(
builderImage
);
Assert
.
state
(
runImageStackId
.
equals
(
builderImageStackId
),
"Run image stack '"
+
runImageStackId
+
"' does not match builder stack '"
+
builderImageStackId
+
"'"
);
Assert
.
state
(
runImageStackId
.
equals
(
builderImageStackId
),
()
->
"Run image stack '"
+
runImageStackId
+
"' does not match builder stack '"
+
builderImageStackId
+
"'"
);
}
private
void
executeLifecycle
(
BuildRequest
request
,
EphemeralBuilder
builder
)
throws
IOException
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarModeLibrary.java
View file @
e1819823
...
...
@@ -65,7 +65,7 @@ public class JarModeLibrary extends Library {
public
InputStream
openStream
()
throws
IOException
{
String
path
=
"META-INF/jarmode/"
+
getCoordinates
().
getArtifactId
()
+
".jar"
;
URL
resource
=
getClass
().
getClassLoader
().
getResource
(
path
);
Assert
.
state
(
resource
!=
null
,
"Unable to find resource "
+
path
);
Assert
.
state
(
resource
!=
null
,
()
->
"Unable to find resource "
+
path
);
return
resource
.
openStream
();
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java
View file @
e1819823
...
...
@@ -94,7 +94,7 @@ public abstract class Packager {
protected
Packager
(
File
source
,
LayoutFactory
layoutFactory
)
{
Assert
.
notNull
(
source
,
"Source file must not be null"
);
Assert
.
isTrue
(
source
.
exists
()
&&
source
.
isFile
(),
"Source must refer to an existing file, got "
+
source
.
getAbsolutePath
());
()
->
"Source must refer to an existing file, got "
+
source
.
getAbsolutePath
());
this
.
source
=
source
.
getAbsoluteFile
();
this
.
layoutFactory
=
layoutFactory
;
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/layer/CustomLayers.java
View file @
e1819823
...
...
@@ -64,7 +64,7 @@ public class CustomLayers implements Layers {
Layer
layer
=
selector
.
getLayer
();
Assert
.
state
(
layer
!=
null
,
"Missing content selector layer"
);
Assert
.
state
(
layers
.
contains
(
layer
),
"Content selector layer '"
+
selector
.
getLayer
()
+
"' not found in "
+
layers
);
()
->
"Content selector layer '"
+
selector
.
getLayer
()
+
"' not found in "
+
layers
);
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayersIndexTests.java
View file @
e1819823
...
...
@@ -130,7 +130,7 @@ class LayersIndexTests {
String
actualContent
=
getContent
();
String
name
=
"LayersIndexTests-"
+
LayersIndexTests
.
this
.
testMethodName
+
".txt"
;
InputStream
in
=
LayersIndexTests
.
class
.
getResourceAsStream
(
name
);
Assert
.
state
(
in
!=
null
,
"Can't read "
+
name
);
Assert
.
state
(
in
!=
null
,
()
->
"Can't read "
+
name
);
String
expectedContent
=
new
String
(
FileCopyUtils
.
copyToByteArray
(
in
),
StandardCharsets
.
UTF_8
);
expectedContent
=
expectedContent
.
replace
(
"\r"
,
""
);
assertThat
(
actualContent
).
isEqualTo
(
expectedContent
);
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java
View file @
e1819823
...
...
@@ -105,7 +105,7 @@ class ConfigDataLoaders {
}
}
}
Assert
.
state
(
result
!=
null
,
"No loader found for location '"
+
location
+
"'"
);
Assert
.
state
(
result
!=
null
,
()
->
"No loader found for location '"
+
location
+
"'"
);
return
result
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationContextInitializer.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -92,7 +92,7 @@ public class DelegatingApplicationContextInitializer
Class
<?>
requireContextClass
=
GenericTypeResolver
.
resolveTypeArgument
(
initializerClass
,
ApplicationContextInitializer
.
class
);
Assert
.
isAssignable
(
requireContextClass
,
contextClass
,
String
.
format
(
()
->
String
.
format
(
"Could not add context initializer [%s] as its generic parameter [%s] is not assignable "
+
"from the type of application context used by this context loader [%s]: "
,
initializerClass
.
getName
(),
requireContextClass
.
getName
(),
contextClass
.
getName
()));
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationListener.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -81,7 +81,7 @@ public class DelegatingApplicationListener implements ApplicationListener<Applic
try
{
Class
<?>
clazz
=
ClassUtils
.
forName
(
className
,
ClassUtils
.
getDefaultClassLoader
());
Assert
.
isAssignable
(
ApplicationListener
.
class
,
clazz
,
"class ["
+
className
+
"] must implement ApplicationListener"
);
()
->
"class ["
+
className
+
"] must implement ApplicationListener"
);
listeners
.
add
((
ApplicationListener
<
ApplicationEvent
>)
BeanUtils
.
instantiateClass
(
clazz
));
}
catch
(
Exception
ex
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBean.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -249,7 +249,7 @@ public final class ConfigurationPropertiesBean {
static
ConfigurationPropertiesBean
forValueObject
(
Class
<?>
beanClass
,
String
beanName
)
{
ConfigurationPropertiesBean
propertiesBean
=
create
(
beanName
,
null
,
beanClass
,
null
);
Assert
.
state
(
propertiesBean
!=
null
&&
propertiesBean
.
getBindMethod
()
==
BindMethod
.
VALUE_OBJECT
,
"Bean '"
+
beanName
+
"' is not a @ConfigurationProperties value object"
);
()
->
"Bean '"
+
beanName
+
"' is not a @ConfigurationProperties value object"
);
return
propertiesBean
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindConstructorProvider.java
View file @
e1819823
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -67,9 +67,9 @@ class ConfigurationPropertiesBindConstructorProvider implements BindConstructorP
for
(
Constructor
<?>
candidate
:
candidates
)
{
if
(
MergedAnnotations
.
from
(
candidate
).
isPresent
(
ConstructorBinding
.
class
))
{
Assert
.
state
(
candidate
.
getParameterCount
()
>
0
,
type
.
getName
()
+
" declares @ConstructorBinding on a no-args constructor"
);
()
->
type
.
getName
()
+
" declares @ConstructorBinding on a no-args constructor"
);
Assert
.
state
(
constructor
==
null
,
type
.
getName
()
+
" has more than one @ConstructorBinding constructor"
);
()
->
type
.
getName
()
+
" has more than one @ConstructorBinding constructor"
);
constructor
=
candidate
;
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/PeriodStyle.java
View file @
e1819823
...
...
@@ -48,7 +48,7 @@ public enum PeriodStyle {
}
Matcher
matcher
=
matcher
(
value
);
Assert
.
state
(
matcher
.
matches
(),
"Does not match simple period pattern"
);
Assert
.
isTrue
(
hasAtLeastOneGroupValue
(
matcher
),
"'"
+
value
+
"' is not a valid simple period"
);
Assert
.
isTrue
(
hasAtLeastOneGroupValue
(
matcher
),
()
->
"'"
+
value
+
"' is not a valid simple period"
);
int
years
=
parseInt
(
matcher
,
1
);
int
months
=
parseInt
(
matcher
,
2
);
int
weeks
=
parseInt
(
matcher
,
3
);
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/VolumeMountDirectoryPropertySource.java
View file @
e1819823
...
...
@@ -100,8 +100,8 @@ public class VolumeMountDirectoryPropertySource extends EnumerablePropertySource
private
VolumeMountDirectoryPropertySource
(
String
name
,
Path
sourceDirectory
,
Set
<
Option
>
options
)
{
super
(
name
,
sourceDirectory
);
Assert
.
isTrue
(
Files
.
exists
(
sourceDirectory
),
"Directory '"
+
sourceDirectory
+
"' does not exist"
);
Assert
.
isTrue
(
Files
.
isDirectory
(
sourceDirectory
),
"File '"
+
sourceDirectory
+
"' is not a directory"
);
Assert
.
isTrue
(
Files
.
exists
(
sourceDirectory
),
()
->
"Directory '"
+
sourceDirectory
+
"' does not exist"
);
Assert
.
isTrue
(
Files
.
isDirectory
(
sourceDirectory
),
()
->
"File '"
+
sourceDirectory
+
"' is not a directory"
);
this
.
propertyFiles
=
PropertyFile
.
findAll
(
sourceDirectory
,
options
);
this
.
options
=
options
;
this
.
names
=
StringUtils
.
toStringArray
(
this
.
propertyFiles
.
keySet
());
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java
View file @
e1819823
...
...
@@ -286,7 +286,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
private
LoggerContext
getLoggerContext
()
{
ILoggerFactory
factory
=
StaticLoggerBinder
.
getSingleton
().
getLoggerFactory
();
Assert
.
isInstanceOf
(
LoggerContext
.
class
,
factory
,
String
.
format
(
()
->
String
.
format
(
"LoggerFactory is not a Logback LoggerContext but Logback is on "
+
"the classpath. Either remove Logback or the competing "
+
"implementation (%s loaded from %s). If you are using "
...
...
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