Skip to content

Commit 3cd269b

Browse files
committed
Tidy up and return kinda unrelated change
1 parent 7f5a453 commit 3cd269b

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.nio.file.FileSystem;
2222
import java.nio.file.Files;
2323
import java.nio.file.Path;
24-
import java.util.Arrays;
2524
import java.util.List;
2625
import java.util.Map;
2726

@@ -64,7 +63,7 @@ void defaultFs(
6463
@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path cwd,
6564
@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path userHome)
6665
throws Exception {
67-
invoke(cwd, userHome, Arrays.asList("clean", "verify"));
66+
invoke(cwd, userHome, List.of("verify"));
6867
}
6968

7069
@Test
@@ -93,7 +92,7 @@ void conflictingExtensions(
9392
Path userExtensions = userConf.resolve("extensions.xml");
9493
Files.writeString(userExtensions, extensionsXml);
9594

96-
assertThrows(InvokerException.class, () -> invoke(cwd, userHome, Arrays.asList("clean", "verify")));
95+
assertThrows(InvokerException.class, () -> invoke(cwd, userHome, List.of("verify")));
9796
}
9897

9998
@Test
@@ -162,7 +161,7 @@ void conflictingSettings(
162161
@Test
163162
void jimFs() throws Exception {
164163
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
165-
invoke(fs.getPath("/cwd"), fs.getPath("/home"), Arrays.asList("clean", "verify"));
164+
invoke(fs.getPath("/cwd"), fs.getPath("/home"), List.of("verify"));
166165
}
167166
}
168167
}

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/resident/ResidentMavenInvokerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import java.nio.file.FileSystem;
2222
import java.nio.file.Path;
23-
import java.util.Arrays;
23+
import java.util.List;
2424

2525
import com.google.common.jimfs.Configuration;
2626
import com.google.common.jimfs.Jimfs;
@@ -59,14 +59,14 @@ void defaultFs(
5959
@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path cwd,
6060
@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path userHome)
6161
throws Exception {
62-
invoke(cwd, userHome, Arrays.asList("clean", "verify"));
62+
invoke(cwd, userHome, List.of("verify"));
6363
}
6464

6565
@Disabled("Until we move off fully from File")
6666
@Test
6767
void jimFs() throws Exception {
6868
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
69-
invoke(fs.getPath("/cwd"), fs.getPath("/home"), Arrays.asList("clean", "verify"));
69+
invoke(fs.getPath("/cwd"), fs.getPath("/home"), List.of("verify"));
7070
}
7171
}
7272
}

impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public int hashCode() {
116116
protected final boolean cacheContexts;
117117
protected final boolean useMavenArgsEnv;
118118
protected final AtomicBoolean closed;
119+
protected final InputStream originalStdin;
120+
protected final PrintStream originalStdout;
121+
protected final PrintStream originalStderr;
119122
protected final Properties originalProperties;
120123
protected final ClassLoader originalClassLoader;
121124
protected final ConcurrentHashMap<Key, Context> contexts;
@@ -128,6 +131,9 @@ public EmbeddedMavenExecutor(boolean cacheContexts, boolean useMavenArgsEnv) {
128131
this.cacheContexts = cacheContexts;
129132
this.useMavenArgsEnv = useMavenArgsEnv;
130133
this.closed = new AtomicBoolean(false);
134+
this.originalStdin = System.in;
135+
this.originalStdout = System.out;
136+
this.originalStderr = System.err;
131137
this.originalClassLoader = Thread.currentThread().getContextClassLoader();
132138
this.contexts = new ConcurrentHashMap<>();
133139
this.originalProperties = new Properties();
@@ -152,6 +158,9 @@ public int execute(ExecutorRequest executorRequest) throws ExecutorException {
152158
try {
153159
disposeRuntimeCreatedRealms(context);
154160
} finally {
161+
System.setIn(originalStdin);
162+
System.setOut(originalStdout);
163+
System.setErr(originalStderr);
155164
Thread.currentThread().setContextClassLoader(originalClassLoader);
156165
System.setProperties(originalProperties);
157166
if (!cacheContexts) {

0 commit comments

Comments
 (0)