use of com.google.gerrit.server.git.validators.ValidationMessage in project gerrit by GerritCodeReview.
the class ReceiveCommits method sendMessages.
/**
* Sends all messages which have been collected while processing the push to the client.
*
* <p><strong>Attention:</strong>{@link AsyncReceiveCommits} may call this method while {@link
* #processCommands(Collection, MultiProgressMonitor)} is still running (if the execution of
* processCommands takes too long and AsyncReceiveCommits gets a timeout). This means that local
* variables that are accessed in this method must be thread-safe (otherwise we may hit a {@link
* java.util.ConcurrentModificationException} if we read a variable here that at the same time is
* updated by the background thread that still executes processCommands).
*/
void sendMessages() {
try (TraceContext traceContext = TraceContext.newTrace(loggingTags.containsKey(RequestId.Type.TRACE_ID.name()), loggingTags.get(RequestId.Type.TRACE_ID.name()), (tagName, traceId) -> {
})) {
loggingTags.forEach((tagName, tagValue) -> traceContext.addTag(tagName, tagValue));
for (ValidationMessage m : messages) {
String msg = m.getType().getPrefix() + m.getMessage();
logger.atFine().log("Sending message: %s", msg);
// Avoid calling sendError which will add its own error: prefix.
messageSender.sendMessage(msg);
}
}
}
Aggregations