Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] compiler errors should be parsed properly and handle bytestream…
Browse files Browse the repository at this point in the history
… provider uri | #BAZEL-763 Done

Merge-request: BAZEL-MR-668
Merged-by: Marcin Abramowicz <marcin.abramowicz@jetbrains.com>
  • Loading branch information
abrams27 authored and qodana-bot committed Nov 30, 2023
1 parent c4405b7 commit 80ec82c
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.google.devtools.build.v1.PublishBuildToolEventStreamRequest;
import com.google.devtools.build.v1.PublishBuildToolEventStreamResponse;
import com.google.devtools.build.v1.PublishLifecycleEventRequest;
import com.google.protobuf.ByteString;
import com.google.protobuf.Empty;
import io.grpc.stub.StreamObserver;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -177,11 +179,22 @@ private void consumeActionCompletedEvent(BuildEventStreamProtos.BuildEvent event
}
}

@SuppressWarnings("LiteByteStringUtf8")
private void consumeUnsuccessfulActionCompletedEvent(
BuildEventStreamProtos.ActionExecuted actionEvent, String label) {
String stdErrText = actionEvent.getStderr().toByteString().toStringUtf8();
processDiagnosticText(stdErrText, label);
if (actionEvent.getStderr().getFileCase() == BuildEventStreamProtos.File.FileCase.URI) {
try {
var path = Paths.get(URI.create(actionEvent.getStderr().getUri()));
String stdErrText = Files.readString(path);
processDiagnosticText(stdErrText, label);
} catch (FileSystemNotFoundException | IOException e) {
LOGGER.warn(e);
}
} else if (actionEvent.getStderr().getFileCase()
== BuildEventStreamProtos.File.FileCase.CONTENTS) {
processDiagnosticText(actionEvent.getStderr().getContents().toStringUtf8(), label);
} else {
processDiagnosticText("", label);
}
}

private void processDiagnosticText(String stdErrText, String targetLabel) {
Expand Down

0 comments on commit 80ec82c

Please sign in to comment.