Skip to content

Commit f701dc0

Browse files
nmck257Nick McKinney
andauthored
ChangeSpringPropertyKey no longer expands entire affected yaml (#272)
* ChangeSpringPropertyKey no longer expands entire affected yaml * test fix Co-authored-by: Nick McKinney <[email protected]>
1 parent cfd91d8 commit f701dc0

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,13 @@ protected List<SourceFile> visit(List<SourceFile> before, ExecutionContext ctx)
7070
new org.openrewrite.properties.ChangePropertyKey(oldPropertyKey, newPropertyKey, true, null, false);
7171
org.openrewrite.properties.ChangePropertyKey subpropertiesChangePropertyKey =
7272
new org.openrewrite.properties.ChangePropertyKey(Pattern.quote(oldPropertyKey + ".") + exceptRegex() + "(.*)", newPropertyKey + ".$1", true, null, true);
73-
ExpandProperties expandYaml = new ExpandProperties();
7473
return ListUtils.map(before, s -> {
7574
if (s instanceof Yaml.Documents) {
76-
Yaml.Documents after = (Yaml.Documents) yamlChangePropertyKey.getVisitor().visit(s, ctx);
77-
if (after != s) {
78-
s = (Yaml.Documents) expandYaml.getVisitor().visit(after, ctx);
79-
}
75+
s = (Yaml.Documents) yamlChangePropertyKey.getVisitor().visit(s, ctx);
8076
} else if (s instanceof Properties.File) {
8177
s = (Properties.File) propertiesChangePropertyKey.getVisitor().visit(s, ctx);
8278
s = (Properties.File) subpropertiesChangePropertyKey.getVisitor().visit(s, ctx);
8379
}
84-
8580
return s;
8681
});
8782
}

src/test/java/org/openrewrite/java/spring/ChangeSpringPropertyKeyTest.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void changeLastKey() {
4545
""",
4646
"""
4747
server:
48-
servlet:
49-
path: /tmp/my-server-path
48+
servlet.path: /tmp/my-server-path
5049
"""
5150
)
5251
);
@@ -75,10 +74,7 @@ void changePropertyPath() {
7574
"""
7675
server:
7776
port: 8888
78-
servlet:
79-
session:
80-
cookie:
81-
path: /tmp/my-server-path
77+
servlet.session.cookie.path: /tmp/my-server-path
8278
"""
8379
)
8480
);
@@ -113,15 +109,14 @@ void subproperties() {
113109
""",
114110
"""
115111
spring:
116-
web:
117-
resources:
118-
chain:
119-
strategy:
120-
content:
121-
enabled: true
122-
paths:
123-
- /foo/**
124-
- /bar/**
112+
web.resources:
113+
chain:
114+
strategy:
115+
content:
116+
enabled: true
117+
paths:
118+
- /foo/**
119+
- /bar/**
125120
"""
126121
)
127122
);

src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/boot2/UpgradeSpringBoot2ConfigurationTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ void activateOnProfileDoNotMoveActivate() {
6868
active: dev
6969
---
7070
spring:
71-
config:
72-
activate:
73-
on-profile: prod
71+
config.activate.on-profile: prod
7472
""",
7573
s -> s.path("src/main/resources/application.yml")
7674
)

0 commit comments

Comments
 (0)