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
a1b71ef9
Commit
a1b71ef9
authored
Dec 05, 2018
by
hdeadman
Committed by
Stephane Nicoll
Dec 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid NPE when replacement property does not exist
See gh-15394
parent
6906859a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
+29
-0
PropertiesMigrationReporter.java
...text/properties/migrator/PropertiesMigrationReporter.java
+3
-0
PropertiesMigrationReporterTests.java
...properties/migrator/PropertiesMigrationReporterTests.java
+13
-0
config-error-invalid-replacement.properties
...ources/config/config-error-invalid-replacement.properties
+1
-0
sample-metadata-invalid-replacement.json
...sources/metadata/sample-metadata-invalid-replacement.json
+12
-0
No files found.
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java
View file @
a1b71ef9
...
...
@@ -137,6 +137,9 @@ class PropertiesMigrationReporter {
if
(
lastDot
!=
-
1
)
{
ConfigurationMetadataProperty
property
=
this
.
allProperties
.
get
(
fullId
.
substring
(
0
,
lastDot
));
if
(
property
==
null
)
{
return
null
;
}
String
type
=
property
.
getType
();
if
(
type
!=
null
&&
type
.
startsWith
(
Map
.
class
.
getName
()))
{
int
lastComma
=
type
.
lastIndexOf
(
','
);
...
...
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java
View file @
a1b71ef9
...
...
@@ -152,6 +152,19 @@ public class PropertiesMigrationReporterTests {
+
"'test.inconvertible' uses an incompatible target type"
);
}
@Test
public
void
invalidReplacementHandled
()
throws
IOException
{
this
.
environment
.
getPropertySources
().
addFirst
(
loadPropertySource
(
"first"
,
"config/config-error-invalid-replacement.properties"
));
String
report
=
createErrorReport
(
loadRepository
(
"metadata/sample-metadata-invalid-replacement.json"
));
assertThat
(
report
).
isNotNull
();
assertThat
(
report
).
containsSubsequence
(
"Property source 'first'"
,
"deprecated.six.test"
,
"Line: 1"
,
"Reason"
,
"Replacement key 'does.not.exist' uses an incompatible target type"
);
assertThat
(
report
).
doesNotContain
(
"null"
);
}
private
List
<
String
>
mapToNames
(
PropertySources
sources
)
{
List
<
String
>
names
=
new
ArrayList
<>();
for
(
PropertySource
<?>
source
:
sources
)
{
...
...
spring-boot-project/spring-boot-properties-migrator/src/test/resources/config/config-error-invalid-replacement.properties
0 → 100644
View file @
a1b71ef9
deprecated.six.test
=
abc
spring-boot-project/spring-boot-properties-migrator/src/test/resources/metadata/sample-metadata-invalid-replacement.json
0 → 100644
View file @
a1b71ef9
{
"properties"
:
[
{
"name"
:
"deprecated.six.test"
,
"type"
:
"java.lang.String"
,
"deprecation"
:
{
"replacement"
:
"does.not.exist"
,
"level"
:
"error"
}
}
]
}
\ No newline at end of file
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