flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject flink git commit: [FLINK-2381] Stringify cause of ProducerFailedExceptions
Date Fri, 24 Jul 2015 11:57:19 GMT
Repository: flink
Updated Branches:
  refs/heads/release-0.9 d71e65b8b -> 198406fbb


[FLINK-2381] Stringify cause of ProducerFailedExceptions


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/198406fb
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/198406fb
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/198406fb

Branch: refs/heads/release-0.9
Commit: 198406fbb0b0c8a3fd050070bdb82170502f16ba
Parents: d71e65b
Author: Ufuk Celebi <uce@apache.org>
Authored: Fri Jul 24 13:42:07 2015 +0200
Committer: Ufuk Celebi <uce@apache.org>
Committed: Fri Jul 24 13:57:00 2015 +0200

----------------------------------------------------------------------
 .../partition/ProducerFailedException.java      | 23 +++++++++-
 .../partition/ProducerFailedExceptionTest.java  | 45 ++++++++++++++++++++
 2 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/198406fb/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ProducerFailedException.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ProducerFailedException.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ProducerFailedException.java
index 60da409..2b2acab 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ProducerFailedException.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ProducerFailedException.java
@@ -19,14 +19,33 @@
 package org.apache.flink.runtime.io.network.partition;
 
 import org.apache.flink.runtime.execution.CancelTaskException;
+import org.apache.flink.util.ExceptionUtils;
 
+/**
+ * Network-stack level Exception to notify remote receiver about a failed
+ * partition producer.
+ */
 public class ProducerFailedException extends CancelTaskException {
 
 	private static final long serialVersionUID = -1555492656299526395L;
 
-	private final Throwable cause;
+	private final String causeAsString;
 
+	/**
+	 * The cause of the producer failure.
+	 *
+	 * Note: The cause will be stringified, because it might be an instance of
+	 * a user level Exception, which can not be deserialized by the remote
+	 * receiver's system class loader.
+	 */
 	public ProducerFailedException(Throwable cause) {
-		this.cause = cause;
+		this.causeAsString = cause != null ? ExceptionUtils.stringifyException(cause) : null;
+	}
+
+	/**
+	 * Returns the stringified cause of the producer failure.
+	 */
+	public String getCauseAsString() {
+		return causeAsString;
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/198406fb/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ProducerFailedExceptionTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ProducerFailedExceptionTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ProducerFailedExceptionTest.java
new file mode 100644
index 0000000..aa3f7da
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ProducerFailedExceptionTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.execution.CancelTaskException;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class ProducerFailedExceptionTest {
+
+	@Test
+	public void testInstanceOfCancelTaskException() throws Exception {
+		ProducerFailedException e = new ProducerFailedException(new Exception());
+		assertTrue(e instanceof CancelTaskException);
+	}
+
+	@Test
+	public void testCauseIsStringified() throws Exception {
+		// Tests that the cause is stringified, because it might be an instance
+		// of a user level Exception, which can not be deserialized by the
+		// remote receiver's system class loader.
+		ProducerFailedException e = new ProducerFailedException(new Exception());
+		assertNull(e.getCause());
+		assertNotNull(e.getCauseAsString());
+	}
+}


Mime
View raw message