Skip to content

Commit

Permalink
Have BlazeCommandDispatcher use a NOOP ExtendedEventHandler on second…
Browse files Browse the repository at this point in the history
… parse

- this avoids log spam of option parsing issues

Work towards bazelbuild#18513

PiperOrigin-RevId: 715944733
Change-Id: I75f0e01e4cb2c03dddc08a5580d528c2f6e91c18
  • Loading branch information
kylecarlstrom-google authored and copybara-github committed Jan 15, 2025
1 parent 0db49b8 commit 73b2e33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
*/
public interface ExtendedEventHandler extends EventHandler {

public static final ExtendedEventHandler NOOP =
new ExtendedEventHandler() {
@Override
public void handle(Event event) {}

@Override
public void post(Postable obj) {}
};

/** An event that can be posted via the extended event handler. */
interface Postable extends Reportable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.events.EventKind;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;
import com.google.devtools.build.lib.events.PrintingEventHandler;
import com.google.devtools.build.lib.events.Reporter;
Expand Down Expand Up @@ -648,8 +649,10 @@ private BlazeCommandResult execExclusively(
runtime, workspace, command, commandAnnotation, optionsParser, invocationPolicy);
ImmutableList.Builder<OptionAndRawValue> invocationPolicyFlagListBuilder =
ImmutableList.builder();
// Do not handle any events since this is the second time we parse the options.
earlyExitCode =
optionHandler.parseOptions(args, reporter, invocationPolicyFlagListBuilder);
optionHandler.parseOptions(
args, ExtendedEventHandler.NOOP, invocationPolicyFlagListBuilder);
env.setInvocationPolicyFlags(invocationPolicyFlagListBuilder.build());
}
if (!earlyExitCode.isSuccess()) {
Expand Down

0 comments on commit 73b2e33

Please sign in to comment.