Skip to content

Commit

Permalink
Address PR feedback.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Sep 28, 2022
1 parent aaa4fda commit 4412631
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public static String getError() {
return ThreadContext.get(ERROR_KEY);
}

/**
* Clear saved error messages.
*/
public static void clearError() {
ThreadContext.remove(ERROR_KEY);
}


/**
* Wraps a given instance of {@link Runnable} into a new one which gets all the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
Metrics.getInstance().getNumericalMetric(MetricName.REQ_TOTAL).increment();
Metrics.getInstance().getNumericalMetric(MetricName.REQ_COUNT_TOTAL).increment();

QueryContext.clearError();
QueryContext.addRequestId();

try {
Expand Down Expand Up @@ -276,7 +277,7 @@ private static boolean isExplainRequest(final RestRequest request) {
return request.path().endsWith("/_explain");
}

public static boolean isClientError(Exception e) {
private static boolean isClientError(Exception e) {
return e instanceof NullPointerException // NPE is hard to differentiate but more likely caused by bad query
|| e instanceof SqlParseException
|| e instanceof ParserException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public List<ReplacedRoute> replacedRoutes() {
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {

QueryContext.clearError();
QueryContext.addRequestId();

try {
Expand Down

0 comments on commit 4412631

Please sign in to comment.