Skip to content

Commit f5c8a88

Browse files
committed
Isolate CLI integration tests from any settings decryption failures
1 parent 4d4cc07 commit f5c8a88

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

spring-boot-cli/src/it/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import java.io.FileFilter;
2222
import java.io.IOException;
2323
import java.io.InputStream;
24+
import java.io.PrintWriter;
2425
import java.io.StringReader;
26+
import java.io.StringWriter;
2527
import java.util.ArrayList;
2628
import java.util.Arrays;
2729
import java.util.List;
@@ -99,16 +101,31 @@ public Invocation(Process process) {
99101
}
100102

101103
public String getErrorOutput() {
102-
return this.err.toString();
104+
return postProcessLines(getLines(this.err));
103105
}
104106

105107
public String getStandardOutput() {
106-
return this.out.toString();
108+
return postProcessLines(getStandardOutputLines());
107109
}
108110

109111
public List<String> getStandardOutputLines() {
110-
BufferedReader reader = new BufferedReader(new StringReader(
111-
this.out.toString()));
112+
return getLines(this.out);
113+
}
114+
115+
private String postProcessLines(List<String> lines) {
116+
StringWriter out = new StringWriter();
117+
PrintWriter printOut = new PrintWriter(out);
118+
for (String line : lines) {
119+
if (!line.startsWith("Maven settings decryption failed")) {
120+
printOut.println(line);
121+
}
122+
}
123+
return out.toString();
124+
}
125+
126+
private List<String> getLines(StringBuffer buffer) {
127+
BufferedReader reader = new BufferedReader(
128+
new StringReader(buffer.toString()));
112129
String line;
113130
List<String> lines = new ArrayList<String>();
114131
try {
@@ -117,7 +134,7 @@ public List<String> getStandardOutputLines() {
117134
}
118135
}
119136
catch (IOException ex) {
120-
throw new RuntimeException("Failed to read standard output");
137+
throw new RuntimeException("Failed to read output");
121138
}
122139
return lines;
123140
}

spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/SettingsXmlRepositorySystemSessionAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void apply(DefaultRepositorySystemSession session,
7777
Settings settings = loadSettings();
7878
SettingsDecryptionResult decryptionResult = decryptSettings(settings);
7979
if (!decryptionResult.getProblems().isEmpty()) {
80-
Log.error("Settings decryption failed: " + decryptionResult.getProblems());
80+
Log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible");
8181
// Continue - the encrypted credentials may not be used
8282
}
8383

0 commit comments

Comments
 (0)