sv2000 commented on a change in pull request #3289:
URL: https://github.com/apache/gobblin/pull/3289#discussion_r657370037
##########
File path:
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/fork/Fork.java
##########
@@ -24,6 +24,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.github.rholder.retry.RetryException;
Review comment:
Unused import.
##########
File path:
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/fork/Fork.java
##########
@@ -50,12 +51,14 @@
import org.apache.gobblin.records.RecordStreamWithMetadata;
import org.apache.gobblin.runtime.BoundedBlockingRecordQueue;
import org.apache.gobblin.runtime.ExecutionModel;
+import org.apache.gobblin.runtime.ForkException;
Review comment:
Unused import.
##########
File path:
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/ExceptionCleanupUtils.java
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.runtime.util;
+
+public final class ExceptionCleanupUtils {
+
+ private ExceptionCleanupUtils() {
+ }
+
+ /**
+ * Removes exceptions that were wrapping another exception without providing
a message of their own.
+ *
+ * When a checked exception is defined on the interface, and one of the
implementations want to propagate a
+ * different type of exception, that implementation can wrap the original
exception. For example, Gobblin
+ * codebase frequently wraps exception into new IOException(cause). As a
result, users see large stack traces
+ * where real error is hidden below several wrappers. This method will
remove the wrappers to provide users with
+ * better error messages.
+ * */
+ public static Throwable removeEmptyWrappers(Throwable exception) {
+ if (exception == null) {
+ return null;
+ }
+
+ if (exception.getCause() != null &&
exception.getCause().toString().equals(exception.getMessage())) {
+ return removeEmptyWrappers(exception.getCause());
+ }
+
+ return exception;
+ }
+ /**
+ * The method will return the bottom of the exception stack, up to one of
the provided wrappers.
+ *
+ * It is useful when exception can be wrapped multiple times in the
codebase, and only some of those wrappings
+ * can contain useful information, while others will just confuse the user.
+ *
+ * Examples: if the chain is wrapper1 -> wrapper2 -> real1 -> real2, the
method will return real1 -> real2 chain.
+ * */
+ public static Throwable getRootCauseUpToWrapper(Throwable exception,
Class<?>... wrapperExceptionTypes) {
Review comment:
Is this method used anywhere other than test class?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]