You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2018/01/18 17:09:32 UTC

[15/17] flink git commit: [hotfix] [core] Move 'ThrowingConsumer' and 'RunnableWithException' to proper package (.util.function)

[hotfix] [core] Move 'ThrowingConsumer' and 'RunnableWithException' to proper package (.util.function)

This also adds missing stability annotations to the functional interfaces in 'util.function'.


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

Branch: refs/heads/master
Commit: 1e6a91a3bf7e734eccdb034ce505b3775b709265
Parents: edc6f10
Author: Stephan Ewen <se...@apache.org>
Authored: Thu Jan 18 14:15:49 2018 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Thu Jan 18 18:08:04 2018 +0100

----------------------------------------------------------------------
 .../org/apache/flink/util/ExceptionUtils.java   |  7 +---
 .../java/org/apache/flink/util/LambdaUtil.java  |  2 +
 .../org/apache/flink/util/ThrowingConsumer.java | 37 ------------------
 .../util/function/RunnableWithException.java    | 38 +++++++++++++++++++
 .../util/function/SupplierWithException.java    |  3 ++
 .../flink/util/function/ThrowingConsumer.java   | 40 ++++++++++++++++++++
 6 files changed, 84 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java b/flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java
index e36ea2b..6e0a9c6 100644
--- a/flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java
@@ -25,6 +25,7 @@
 package org.apache.flink.util;
 
 import org.apache.flink.annotation.Internal;
+import org.apache.flink.util.function.RunnableWithException;
 
 import javax.annotation.Nullable;
 import java.io.IOException;
@@ -396,12 +397,6 @@ public final class ExceptionUtils {
 		}
 	}
 
-	@FunctionalInterface
-	public interface RunnableWithException {
-
-		void run() throws Exception;
-	}
-
 	// ------------------------------------------------------------------------
 
 	/** Private constructor to prevent instantiation. */

http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/LambdaUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/LambdaUtil.java b/flink-core/src/main/java/org/apache/flink/util/LambdaUtil.java
index 8ac0f0e..bce403a 100644
--- a/flink-core/src/main/java/org/apache/flink/util/LambdaUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/LambdaUtil.java
@@ -18,6 +18,8 @@
 
 package org.apache.flink.util;
 
+import org.apache.flink.util.function.ThrowingConsumer;
+
 /**
  * This class offers utility functions for Java's lambda features.
  */

http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/ThrowingConsumer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/ThrowingConsumer.java b/flink-core/src/main/java/org/apache/flink/util/ThrowingConsumer.java
deleted file mode 100644
index a180a12..0000000
--- a/flink-core/src/main/java/org/apache/flink/util/ThrowingConsumer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.util;
-
-/**
- * This interface is basically Java's {@link java.util.function.Consumer} interface enhanced with the ability to throw
- * an exception.
- *
- * @param <T> type of the consumed elements.
- */
-@FunctionalInterface
-public interface ThrowingConsumer<T> {
-
-	/**
-	 * Performs this operation on the given argument.
-	 *
-	 * @param t the input argument
-	 * @throws Exception on errors during consumption
-	 */
-	void accept(T t) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/function/RunnableWithException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/function/RunnableWithException.java b/flink-core/src/main/java/org/apache/flink/util/function/RunnableWithException.java
new file mode 100644
index 0000000..6270726
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/util/function/RunnableWithException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.util.function;
+
+import org.apache.flink.annotation.Public;
+
+/**
+ * Similar to a {@link Runnable}, this interface is used to capture a block of code
+ * to be executed. In contrast to {@code Runnable}, this interface allows throwing
+ * checked exceptions.
+ */
+@Public
+@FunctionalInterface
+public interface RunnableWithException {
+
+	/**
+	 * The work method.
+	 *
+	 * @throws Exception Exceptions may be thrown.
+	 */
+	void run() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/function/SupplierWithException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/function/SupplierWithException.java b/flink-core/src/main/java/org/apache/flink/util/function/SupplierWithException.java
index 63be9bf..f584887 100644
--- a/flink-core/src/main/java/org/apache/flink/util/function/SupplierWithException.java
+++ b/flink-core/src/main/java/org/apache/flink/util/function/SupplierWithException.java
@@ -18,6 +18,8 @@
 
 package org.apache.flink.util.function;
 
+import org.apache.flink.annotation.Public;
+
 /**
  * A functional interface for a {@link java.util.function.Supplier} that may
  * throw exceptions.
@@ -25,6 +27,7 @@ package org.apache.flink.util.function;
  * @param <R> The type of the result of the supplier.
  * @param <E> The type of Exceptions thrown by this function.
  */
+@Public
 @FunctionalInterface
 public interface SupplierWithException<R, E extends Throwable> {
 

http://git-wip-us.apache.org/repos/asf/flink/blob/1e6a91a3/flink-core/src/main/java/org/apache/flink/util/function/ThrowingConsumer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/function/ThrowingConsumer.java b/flink-core/src/main/java/org/apache/flink/util/function/ThrowingConsumer.java
new file mode 100644
index 0000000..1452071
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/util/function/ThrowingConsumer.java
@@ -0,0 +1,40 @@
+/*
+ * 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.util.function;
+
+import org.apache.flink.annotation.Public;
+
+/**
+ * This interface is basically Java's {@link java.util.function.Consumer} interface enhanced with the ability to throw
+ * an exception.
+ *
+ * @param <T> type of the consumed elements.
+ */
+@Public
+@FunctionalInterface
+public interface ThrowingConsumer<T> {
+
+	/**
+	 * Performs this operation on the given argument.
+	 *
+	 * @param t the input argument
+	 * @throws Exception on errors during consumption
+	 */
+	void accept(T t) throws Exception;
+}