Let logging framework format exception stack traces (#1954)
Where possible, logging calls are changed so that logging framework handles exception formatting instead of stack trace being manually formatted using Throwable#getStackTrace
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index b7e9fa0..c641b4d 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -904,8 +904,8 @@
pipeline.finish();
} catch (Exception e) {
logger.error(
- "Exception while executing {} pipeline: {} for cluster {}. Will not continue to next pipeline",
- dataProvider.getPipelineName(), _clusterName, Arrays.toString(e.getStackTrace()));
+ "Exception while executing {} pipeline for cluster {}. Will not continue to next pipeline",
+ dataProvider.getPipelineName(), _clusterName, e);
if (e instanceof HelixMetaDataAccessException) {
helixMetaDataAccessRebalanceFail = true;
// If pipeline failed due to read/write fails to zookeeper, retry the pipeline.
diff --git a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestAutoRebalancePartitionLimit.java b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestAutoRebalancePartitionLimit.java
index 2266fb6..0fb203e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestAutoRebalancePartitionLimit.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestAutoRebalancePartitionLimit.java
@@ -225,7 +225,7 @@
numberOfPartitions, masterValue, replicas, cache.getLiveInstances().size(),
cache.getIdealState(_resourceName).getMaxPartitionsPerInstance());
} catch (Exception e) {
- LOG.debug("Verify failed due to {}", e.getStackTrace());
+ LOG.debug("Verify failed", e);
return false;
}
}
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ResourceAssignmentOptimizerAccessor.java b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ResourceAssignmentOptimizerAccessor.java
index e4c0dad..0ecae71 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ResourceAssignmentOptimizerAccessor.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ResourceAssignmentOptimizerAccessor.java
@@ -147,12 +147,11 @@
} catch (JsonProcessingException e) {
return badRequest("Invalid input: Input can not be parsed into a KV map." + e.getMessage());
} catch (OutOfMemoryError e) {
- LOG.error("OutOfMemoryError while calling partitionAssignment" + Arrays
- .toString(e.getStackTrace()));
+ LOG.error("OutOfMemoryError while calling partitionAssignment", e);
return badRequest(
"Response size is too large to serialize. Please query by resources or instance filter");
} catch (Exception e) {
- LOG.error("Failed to compute partition assignment:" + Arrays.toString(e.getStackTrace()));
+ LOG.error("Failed to compute partition assignment", e);
return badRequest("Failed to compute partition assignment: " + e);
}
}
@@ -392,4 +391,4 @@
headers.put(RESPONSE_HEADER_FIELDS[2], inputFields.returnFormat.name());
return headers;
}
-}
\ No newline at end of file
+}