Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ AccessToken getTokenFromAzureCLIAuthentication(StringBuilder azCommand) {
}

ProcessBuilder builder = new ProcessBuilder(starter, switcher, azCommand.toString());
// Redirects stdin to dev null, helps to avoid messages sent in by the cmd process to upgrade etc.
builder.redirectInput(ProcessBuilder.Redirect.from(IdentityUtil.NULL_FILE));

String workingDirectory = getSafeWorkingDirectory();
if (workingDirectory != null) {
Expand Down Expand Up @@ -619,6 +621,8 @@ AccessToken getTokenFromAzureDeveloperCLIAuthentication(StringBuilder azdCommand
}

ProcessBuilder builder = new ProcessBuilder(starter, switcher, azdCommand.toString());
// Redirects stdin to dev null, helps to avoid messages sent in by the cmd process to upgrade etc.
builder.redirectInput(ProcessBuilder.Redirect.from(IdentityUtil.NULL_FILE));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. could you add a comment here mentioning why we're doing the redirection
  2. could you include a test case in the PR for the scenario


String workingDirectory = getSafeWorkingDirectory();
if (workingDirectory != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.identity.BrowserCustomizationOptions;
import com.azure.identity.implementation.IdentityClientOptions;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -22,6 +23,8 @@ public final class IdentityUtil {
public static final String ALL_TENANTS = "*";
public static final String DEFAULT_TENANT = "organizations";

public static final File NULL_FILE =
new File((System.getProperty("os.name").startsWith("Windows") ? "NUL" : "/dev/null"));

private IdentityUtil() { }
/**
Expand Down