1515import java .util .zip .ZipEntry ;
1616import java .util .zip .ZipInputStream ;
1717
18+ import static io .github .intisy .docker .IOUtils .readAllBytes ;
19+
1820/**
1921 * Windows-specific Docker provider.
2022 * Supports both native Windows containers (requires admin) and WSL2-based Docker (no admin required).
@@ -109,7 +111,7 @@ private void ensureWsl2DockerInstalled() throws IOException {
109111 ProcessBuilder checkPb = new ProcessBuilder ("wsl" , "-d" , wslDistro , "-e" , "bash" , "-c" , "command -v dockerd" );
110112 checkPb .redirectErrorStream (true );
111113 Process checkProcess = checkPb .start ();
112- byte [] output = checkProcess .getInputStream (). readAllBytes ( );
114+ byte [] output = readAllBytes ( checkProcess .getInputStream ());
113115 int exitCode = checkProcess .waitFor ();
114116
115117 log .debug ("dockerd check exit code: {}, output: {}" , exitCode , new String (output ).trim ());
@@ -340,7 +342,7 @@ private void startWsl2Docker() throws IOException, InterruptedException {
340342
341343 // Check if process is still running
342344 if (!dockerProcess .isAlive ()) {
343- byte [] output = dockerProcess .getInputStream (). readAllBytes ( );
345+ byte [] output = readAllBytes ( dockerProcess .getInputStream ());
344346 String outputStr = new String (output ).trim ();
345347 log .error ("WSL process died. Output: {}" , outputStr .isEmpty () ? "(empty)" : outputStr );
346348
@@ -423,7 +425,7 @@ private boolean checkPasswordlessSudo() {
423425 "sudo -n dockerd --version >/dev/null 2>&1 && echo yes || echo no" );
424426 pb .redirectErrorStream (true );
425427 Process process = pb .start ();
426- byte [] output = process .getInputStream (). readAllBytes ( );
428+ byte [] output = readAllBytes ( process .getInputStream ());
427429 boolean completed = process .waitFor (5 , TimeUnit .SECONDS );
428430
429431 if (!completed ) {
@@ -450,7 +452,7 @@ private String runWslCommand(String command, boolean useSudo, int timeoutSeconds
450452 ProcessBuilder pb = new ProcessBuilder ("wsl" , "-d" , wslDistro , "-e" , "bash" , "-c" , fullCommand );
451453 pb .redirectErrorStream (true );
452454 Process process = pb .start ();
453- byte [] output = process .getInputStream (). readAllBytes ( );
455+ byte [] output = readAllBytes ( process .getInputStream ());
454456 process .waitFor (timeoutSeconds , TimeUnit .SECONDS );
455457 return new String (output ).trim ();
456458 } catch (IOException | InterruptedException e ) {
@@ -490,7 +492,7 @@ private boolean isAdministrator() {
490492 ProcessBuilder pb = new ProcessBuilder ("net" , "session" );
491493 pb .redirectErrorStream (true );
492494 Process process = pb .start ();
493- byte [] output = process .getInputStream (). readAllBytes ( );
495+ byte [] output = readAllBytes ( process .getInputStream ());
494496 int exitCode = process .waitFor ();
495497 log .debug ("Admin check (net session) exit code: {}" , exitCode );
496498 return exitCode == 0 ;
@@ -510,7 +512,7 @@ private boolean isWsl2Available() {
510512 Process process = pb .start ();
511513
512514 // Read as bytes and convert, handling potential UTF-16 encoding
513- byte [] outputBytes = process .getInputStream (). readAllBytes ( );
515+ byte [] outputBytes = readAllBytes ( process .getInputStream ());
514516 String output = new String (outputBytes , java .nio .charset .StandardCharsets .UTF_16LE );
515517
516518 int exitCode = process .waitFor ();
@@ -564,7 +566,7 @@ private boolean isWsl2Available() {
564566 ProcessBuilder testPb = new ProcessBuilder ("wsl" , "-d" , wslDistro , "-e" , "bash" , "-c" , "echo test" );
565567 testPb .redirectErrorStream (true );
566568 Process testProcess = testPb .start ();
567- testProcess .getInputStream (). readAllBytes ( );
569+ readAllBytes ( testProcess .getInputStream ());
568570 int testExitCode = testProcess .waitFor ();
569571
570572 if (testExitCode == 0 ) {
0 commit comments