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
f823599d
Commit
f823599d
authored
Jan 26, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace @PostConstruct validation with setter validation
Closes gh-7579
parent
9a044d15
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
59 deletions
+19
-59
ManagementServerProperties.java
...oot/actuate/autoconfigure/ManagementServerProperties.java
+1
-6
AbstractEndpoint.java
...ringframework/boot/actuate/endpoint/AbstractEndpoint.java
+5
-11
AbstractMvcEndpoint.java
...mework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java
+5
-11
H2ConsoleProperties.java
...gframework/boot/autoconfigure/h2/H2ConsoleProperties.java
+3
-9
LiquibaseProperties.java
...ork/boot/autoconfigure/liquibase/LiquibaseProperties.java
+1
-7
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+1
-6
WebServicesProperties.java
...boot/autoconfigure/webservices/WebServicesProperties.java
+3
-9
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java
View file @
f823599d
...
...
@@ -20,7 +20,6 @@ import java.net.InetAddress;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.boot.autoconfigure.security.SecurityPrerequisite
;
...
...
@@ -88,11 +87,6 @@ public class ManagementServerProperties implements SecurityPrerequisite {
private
final
Security
security
=
new
Security
();
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
contextPath
,
"ContextPath must not be null"
);
}
/**
* Returns the management port or {@code null} if the
* {@link ServerProperties#getPort() server port} should be used.
...
...
@@ -138,6 +132,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
}
public
void
setContextPath
(
String
contextPath
)
{
Assert
.
notNull
(
contextPath
,
"ContextPath must not be null"
);
this
.
contextPath
=
cleanContextPath
(
contextPath
);
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractEndpoint.java
View file @
f823599d
...
...
@@ -18,8 +18,6 @@ package org.springframework.boot.actuate.endpoint;
import
java.util.regex.Pattern
;
import
javax.annotation.PostConstruct
;
import
org.springframework.context.EnvironmentAware
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.Assert
;
...
...
@@ -55,13 +53,6 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T>, EnvironmentAwa
*/
private
Boolean
enabled
;
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
id
,
"Id must not be null"
);
Assert
.
isTrue
(
ID_PATTERN
.
matcher
(
this
.
id
).
matches
(),
"ID must only contains letters, numbers and '_'"
);
}
/**
* Create a new sensitive endpoint instance. The endpoint will enabled flag will be
* based on the spring {@link Environment} unless explicitly set.
...
...
@@ -78,7 +69,7 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T>, EnvironmentAwa
* @param sensitive if the endpoint is sensitive by default
*/
public
AbstractEndpoint
(
String
id
,
boolean
sensitive
)
{
this
.
id
=
id
;
setId
(
id
)
;
this
.
sensitiveDefault
=
sensitive
;
}
...
...
@@ -89,7 +80,7 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T>, EnvironmentAwa
* @param enabled if the endpoint is enabled or not.
*/
public
AbstractEndpoint
(
String
id
,
boolean
sensitive
,
boolean
enabled
)
{
this
.
id
=
id
;
setId
(
id
)
;
this
.
sensitiveDefault
=
sensitive
;
this
.
enabled
=
enabled
;
}
...
...
@@ -109,6 +100,9 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T>, EnvironmentAwa
}
public
void
setId
(
String
id
)
{
Assert
.
notNull
(
id
,
"Id must not be null"
);
Assert
.
isTrue
(
ID_PATTERN
.
matcher
(
id
).
matches
(),
"Id must only contains letters, numbers and '_'"
);
this
.
id
=
id
;
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java
View file @
f823599d
...
...
@@ -16,8 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
mvc
;
import
javax.annotation.PostConstruct
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.EndpointProperties
;
import
org.springframework.context.EnvironmentAware
;
...
...
@@ -56,23 +54,16 @@ public abstract class AbstractMvcEndpoint extends WebMvcConfigurerAdapter
private
final
boolean
sensitiveDefault
;
public
AbstractMvcEndpoint
(
String
path
,
boolean
sensitive
)
{
this
.
path
=
path
;
setPath
(
path
)
;
this
.
sensitiveDefault
=
sensitive
;
}
public
AbstractMvcEndpoint
(
String
path
,
boolean
sensitive
,
boolean
enabled
)
{
this
.
path
=
path
;
setPath
(
path
)
;
this
.
sensitiveDefault
=
sensitive
;
this
.
enabled
=
enabled
;
}
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
path
,
"Path must not be null"
);
Assert
.
isTrue
(
this
.
path
.
isEmpty
()
||
this
.
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
}
@Override
public
void
setEnvironment
(
Environment
environment
)
{
this
.
environment
=
environment
;
...
...
@@ -88,6 +79,9 @@ public abstract class AbstractMvcEndpoint extends WebMvcConfigurerAdapter
}
public
void
setPath
(
String
path
)
{
Assert
.
notNull
(
path
,
"Path must not be null"
);
Assert
.
isTrue
(
path
.
isEmpty
()
||
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
this
.
path
=
path
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java
View file @
f823599d
...
...
@@ -16,8 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
h2
;
import
javax.annotation.PostConstruct
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.util.Assert
;
...
...
@@ -44,18 +42,14 @@ public class H2ConsoleProperties {
private
final
Settings
settings
=
new
Settings
();
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
path
,
"Path must not be null"
);
Assert
.
isTrue
(
this
.
path
.
isEmpty
()
||
this
.
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
}
public
String
getPath
()
{
return
this
.
path
;
}
public
void
setPath
(
String
path
)
{
Assert
.
notNull
(
path
,
"Path must not be null"
);
Assert
.
isTrue
(
path
.
isEmpty
()
||
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
this
.
path
=
path
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java
View file @
f823599d
...
...
@@ -19,8 +19,6 @@ package org.springframework.boot.autoconfigure.liquibase;
import
java.io.File
;
import
java.util.Map
;
import
javax.annotation.PostConstruct
;
import
liquibase.integration.spring.SpringLiquibase
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
...
...
@@ -96,16 +94,12 @@ public class LiquibaseProperties {
*/
private
File
rollbackFile
;
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
changeLog
,
"ChangeLog must not be null"
);
}
public
String
getChangeLog
()
{
return
this
.
changeLog
;
}
public
void
setChangeLog
(
String
changeLog
)
{
Assert
.
notNull
(
changeLog
,
"ChangeLog must not be null"
);
this
.
changeLog
=
changeLog
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
f823599d
...
...
@@ -26,7 +26,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
javax.annotation.PostConstruct
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.SessionCookieConfig
;
...
...
@@ -176,11 +175,6 @@ public class ServerProperties
private
Environment
environment
;
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
servletPath
,
"ServletPath must not be null"
);
}
@Override
public
int
getOrder
()
{
return
0
;
...
...
@@ -336,6 +330,7 @@ public class ServerProperties
}
public
void
setServletPath
(
String
servletPath
)
{
Assert
.
notNull
(
servletPath
,
"ServletPath must not be null"
);
this
.
servletPath
=
servletPath
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java
View file @
f823599d
...
...
@@ -19,8 +19,6 @@ package org.springframework.boot.autoconfigure.webservices;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.annotation.PostConstruct
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.util.Assert
;
...
...
@@ -41,18 +39,14 @@ public class WebServicesProperties {
private
final
Servlet
servlet
=
new
Servlet
();
@PostConstruct
private
void
validate
()
{
Assert
.
notNull
(
this
.
path
,
"Path must not be null"
);
Assert
.
isTrue
(
this
.
path
.
isEmpty
()
||
this
.
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
}
public
String
getPath
()
{
return
this
.
path
;
}
public
void
setPath
(
String
path
)
{
Assert
.
notNull
(
path
,
"Path must not be null"
);
Assert
.
isTrue
(
path
.
isEmpty
()
||
path
.
startsWith
(
"/"
),
"Path must start with / or be empty"
);
this
.
path
=
path
;
}
...
...
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