From 65a9af8aec91dc1b5a50853f7590f04e02401244 Mon Sep 17 00:00:00 2001 From: Rahul Kesharwani Date: Wed, 9 Oct 2019 17:43:16 +0530 Subject: [PATCH] Removed `BatchingException#toString()` to only log total failure count --- .../google/api/gax/batching/BatcherImpl.java | 2 +- .../api/gax/batching/BatchingException.java | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java b/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java index 60a158ca5..3a080f7ea 100644 --- a/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java +++ b/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java @@ -226,7 +226,7 @@ private void addException(Throwable throwable) { synchronized (errorLock) { if (failureStatusCodeCount.containsKey(code)) { - failureStatusCodeCount.get(code).get(); + failureStatusCodeCount.get(code).incrementAndGet(); } else { failureStatusCodeCount.put(code, new AtomicInteger(1)); } diff --git a/gax/src/main/java/com/google/api/gax/batching/BatchingException.java b/gax/src/main/java/com/google/api/gax/batching/BatchingException.java index a065a9340..ff246daf7 100644 --- a/gax/src/main/java/com/google/api/gax/batching/BatchingException.java +++ b/gax/src/main/java/com/google/api/gax/batching/BatchingException.java @@ -29,7 +29,6 @@ */ package com.google.api.gax.batching; -import com.google.api.gax.rpc.ApiException; import com.google.api.gax.rpc.StatusCode; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -49,6 +48,8 @@ public class BatchingException extends RuntimeException { long numOfFailure, Map exceptionCount, Map statusCodeCount) { + super("Failed to commit " + numOfFailure + " mutations"); + this.numOfFailure = numOfFailure; this.exceptionCount = exceptionCount; this.statusCodeCount = statusCodeCount; @@ -65,23 +66,4 @@ public Map getFailureTypesCount() { public Map getFailureStatusCodeCount() { return statusCodeCount; } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("Failed to commit ") - .append(numOfFailure) - .append(" mutations\n") - .append("Mutations failed for Exception types: ") - .append(exceptionCount.entrySet()) - .append("\n"); - - if (!exceptionCount.isEmpty()) { - sb.append("Total ApiException failure are: ") - .append(exceptionCount.get(ApiException.class)) - .append(" with Status Code as: ") - .append(statusCodeCount.entrySet()); - } - return sb.toString(); - } }