arunpandianp commented on code in PR #38592:
URL: https://github.com/apache/beam/pull/38592#discussion_r3337703043


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/ExceptionUtils.java:
##########
@@ -17,27 +17,25 @@
  */
 package org.apache.beam.runners.dataflow.worker.util;
 
-/** A simple histogram to track byte sizes. */
-public class SimpleByteHistogram {
-  private final long[] buckets = new long[7];
+import org.apache.beam.sdk.annotations.Internal;
 
-  public void add(long weight) {
-    buckets[getBucket(weight)]++;
-  }
+/** Utility methods for simplifying work with exceptions and throwables. */
+@Internal
+public final class ExceptionUtils {
 
-  private int getBucket(long weight) {
-    if (weight < 128) return 0;
-    if (weight < 256) return 1;
-    if (weight < 512) return 2;
-    if (weight < 1024) return 3;
-    if (weight < 10 * 1024) return 4;
-    if (weight < 1024 * 1024) return 5;
-    return 6;
-  }
+  private ExceptionUtils() {}
 
-  public String format() {
-    return String.format(
-        "[<128B:%d, <256B:%d, <512B:%d, <1KB:%d, <10KB:%d, <1MB:%d, >=1MB:%d]",
-        buckets[0], buckets[1], buckets[2], buckets[3], buckets[4], 
buckets[5], buckets[6]);
+  /**
+   * Propagates {@code throwable} as-is if it is an instance of {@link 
RuntimeException} or {@link
+   * Error}, or else as a last resort wraps it in a {@code RuntimeException} 
and then propagates.
+   */
+  public static RuntimeException propagate(Throwable throwable) {

Review Comment:
   Done. Renamed to safeWrapThrowableAsException and added CheckReturnValue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to