|
38 | 38 | import java.io.OutputStream;
|
39 | 39 | import java.io.PrintStream;
|
40 | 40 | import java.io.UncheckedIOException;
|
41 |
| -import java.io.UnsupportedEncodingException; |
42 | 41 | import java.net.MalformedURLException;
|
43 | 42 | import java.nio.charset.StandardCharsets;
|
44 | 43 | import java.nio.file.Files;
|
@@ -591,34 +590,30 @@ public CommandResult(int returnCode, String out, String err, PluginScanResult re
|
591 | 590 | private static CommandResult runCommand(Object... args) {
|
592 | 591 | ByteArrayOutputStream out = new ByteArrayOutputStream();
|
593 | 592 | ByteArrayOutputStream err = new ByteArrayOutputStream();
|
594 |
| - try { |
595 |
| - int returnCode = ConnectPluginPath.mainNoExit( |
596 |
| - Arrays.stream(args) |
597 |
| - .map(Object::toString) |
598 |
| - .collect(Collectors.toList()) |
599 |
| - .toArray(new String[]{}), |
600 |
| - new PrintStream(out, true, "utf-8"), |
601 |
| - new PrintStream(err, true, "utf-8")); |
602 |
| - Set<Path> pluginLocations = getPluginLocations(args); |
603 |
| - ClassLoader parent = ConnectPluginPath.class.getClassLoader(); |
604 |
| - ClassLoaderFactory factory = new ClassLoaderFactory(); |
605 |
| - try (DelegatingClassLoader delegatingClassLoader = factory.newDelegatingClassLoader(parent)) { |
606 |
| - Set<PluginSource> sources = PluginUtils.pluginSources(pluginLocations, delegatingClassLoader, factory); |
607 |
| - String stdout = new String(out.toByteArray(), StandardCharsets.UTF_8); |
608 |
| - String stderr = new String(err.toByteArray(), StandardCharsets.UTF_8); |
609 |
| - log.info("STDOUT:\n{}", stdout); |
610 |
| - log.info("STDERR:\n{}", stderr); |
611 |
| - return new CommandResult( |
612 |
| - returnCode, |
613 |
| - stdout, |
614 |
| - stderr, |
615 |
| - new ReflectionScanner().discoverPlugins(sources), |
616 |
| - new ServiceLoaderScanner().discoverPlugins(sources) |
617 |
| - ); |
618 |
| - } catch (IOException e) { |
619 |
| - throw new RuntimeException(e); |
620 |
| - } |
621 |
| - } catch (UnsupportedEncodingException e) { |
| 593 | + int returnCode = ConnectPluginPath.mainNoExit( |
| 594 | + Arrays.stream(args) |
| 595 | + .map(Object::toString) |
| 596 | + .toList() |
| 597 | + .toArray(new String[]{}), |
| 598 | + new PrintStream(out, true, StandardCharsets.UTF_8), |
| 599 | + new PrintStream(err, true, StandardCharsets.UTF_8)); |
| 600 | + Set<Path> pluginLocations = getPluginLocations(args); |
| 601 | + ClassLoader parent = ConnectPluginPath.class.getClassLoader(); |
| 602 | + ClassLoaderFactory factory = new ClassLoaderFactory(); |
| 603 | + try (DelegatingClassLoader delegatingClassLoader = factory.newDelegatingClassLoader(parent)) { |
| 604 | + Set<PluginSource> sources = PluginUtils.pluginSources(pluginLocations, delegatingClassLoader, factory); |
| 605 | + String stdout = out.toString(StandardCharsets.UTF_8); |
| 606 | + String stderr = err.toString(StandardCharsets.UTF_8); |
| 607 | + log.info("STDOUT:\n{}", stdout); |
| 608 | + log.info("STDERR:\n{}", stderr); |
| 609 | + return new CommandResult( |
| 610 | + returnCode, |
| 611 | + stdout, |
| 612 | + stderr, |
| 613 | + new ReflectionScanner().discoverPlugins(sources), |
| 614 | + new ServiceLoaderScanner().discoverPlugins(sources) |
| 615 | + ); |
| 616 | + } catch (IOException e) { |
622 | 617 | throw new RuntimeException(e);
|
623 | 618 | }
|
624 | 619 | }
|
|
0 commit comments