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:34 UTC
[17/17] flink git commit: [hotfix] [core] Fix checkstyle for
'flink-core' : 'org.apache.flink.util'
[hotfix] [core] Fix checkstyle for 'flink-core' : 'org.apache.flink.util'
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/212ee3d4
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/212ee3d4
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/212ee3d4
Branch: refs/heads/master
Commit: 212ee3d430190e6e771c79a9b94fd8410675a534
Parents: 1e6a91a
Author: Stephan Ewen <se...@apache.org>
Authored: Thu Jan 18 14:41:05 2018 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Thu Jan 18 18:08:04 2018 +0100
----------------------------------------------------------------------
.../flink/util/AbstractCloseableRegistry.java | 4 +-
.../java/org/apache/flink/util/AbstractID.java | 22 ++---
.../org/apache/flink/util/CollectionUtil.java | 3 +
.../java/org/apache/flink/util/Collector.java | 7 +-
.../flink/util/DynamicCodeLoadingException.java | 4 +-
.../org/apache/flink/util/ExceptionUtils.java | 31 +++----
.../java/org/apache/flink/util/FileUtils.java | 36 ++++----
.../org/apache/flink/util/FlinkException.java | 8 +-
.../flink/util/FlinkRuntimeException.java | 8 +-
.../java/org/apache/flink/util/FutureUtil.java | 3 +
.../java/org/apache/flink/util/IOUtils.java | 27 +++---
.../apache/flink/util/InstantiationUtil.java | 93 ++++++++++----------
.../org/apache/flink/util/IterableIterator.java | 3 +-
.../flink/util/LongValueSequenceIterator.java | 17 ++--
.../java/org/apache/flink/util/MathUtils.java | 28 +++---
.../flink/util/MutableObjectIterator.java | 17 ++--
.../java/org/apache/flink/util/NetUtils.java | 57 ++++++------
.../flink/util/NumberSequenceIterator.java | 59 ++++++-------
.../org/apache/flink/util/OperatingSystem.java | 34 +++----
.../java/org/apache/flink/util/OutputTag.java | 8 +-
.../org/apache/flink/util/Preconditions.java | 42 ++++-----
.../org/apache/flink/util/PropertiesUtil.java | 9 +-
.../org/apache/flink/util/ReflectionUtil.java | 25 +++---
.../apache/flink/util/SerializableObject.java | 2 +-
.../apache/flink/util/SerializedThrowable.java | 32 +++----
.../org/apache/flink/util/SerializedValue.java | 6 +-
.../apache/flink/util/SplittableIterator.java | 11 +--
.../flink/util/StateMigrationException.java | 2 +-
.../org/apache/flink/util/StringBasedID.java | 2 +-
.../java/org/apache/flink/util/StringUtils.java | 72 ++++++++-------
.../org/apache/flink/util/StringValueUtils.java | 50 +++++------
.../org/apache/flink/util/UnionIterator.java | 27 ++++--
.../java/org/apache/flink/util/Visitable.java | 17 ++--
.../java/org/apache/flink/util/Visitor.java | 12 ++-
.../org/apache/flink/util/WrappingProxy.java | 7 +-
.../apache/flink/util/WrappingProxyUtil.java | 3 +
.../flink/util/WrappingRuntimeException.java | 4 +-
.../apache/flink/util/ExceptionUtilsTest.java | 6 +-
.../org/apache/flink/util/FileUtilsTest.java | 2 +-
.../flink/util/InstantiationUtilTest.java | 39 ++++----
.../util/LongValueSequenceIteratorTest.java | 19 ++--
.../org/apache/flink/util/MathUtilTest.java | 17 ++--
.../org/apache/flink/util/NetUtilsTest.java | 58 +++++++-----
.../flink/util/NumberSequenceIteratorTest.java | 41 ++++-----
.../org/apache/flink/util/OutputTagTest.java | 5 ++
.../apache/flink/util/ResourceGuardTest.java | 19 ++--
.../apache/flink/util/SerializedValueTest.java | 8 +-
.../org/apache/flink/util/StringUtilsTest.java | 14 +--
.../apache/flink/util/StringValueUtilsTest.java | 16 ++--
.../apache/flink/util/UnionIteratorTest.java | 26 +++---
tools/maven/suppressions-core.xml | 3 -
51 files changed, 568 insertions(+), 497 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java b/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java
index 14e765c..e6589f6 100644
--- a/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java
+++ b/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java
@@ -33,9 +33,9 @@ import java.util.Map;
/**
* This is the abstract base class for registries that allow to register instances of {@link Closeable}, which are all
* closed if this registry is closed.
- *
+ *
* <p>Registering to an already closed registry will throw an exception and close the provided {@link Closeable}
- *
+ *
* <p>All methods in this class are thread-safe.
*
* @param <C> Type of the closeable this registers
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
index 12d634d..41083c6 100644
--- a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
+++ b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
@@ -18,10 +18,10 @@
package org.apache.flink.util;
-import java.util.Random;
-
import org.apache.flink.annotation.PublicEvolving;
+import java.util.Random;
+
/**
* A statistically unique identification number.
*/
@@ -32,25 +32,25 @@ public class AbstractID implements Comparable<AbstractID>, java.io.Serializable
private static final Random RND = new Random();
- /** The size of a long in bytes */
+ /** The size of a long in bytes. */
private static final int SIZE_OF_LONG = 8;
- /** The size of the ID in byte */
+ /** The size of the ID in byte. */
public static final int SIZE = 2 * SIZE_OF_LONG;
// ------------------------------------------------------------------------
- /** The upper part of the actual ID */
+ /** The upper part of the actual ID. */
protected final long upperPart;
- /** The lower part of the actual ID */
+ /** The lower part of the actual ID. */
protected final long lowerPart;
- /** The memoized value returned by toString() */
+ /** The memoized value returned by toString(). */
private String toString;
// --------------------------------------------------------------------------------------------
-
+
/**
* Constructs a new ID with a specific bytes value.
*/
@@ -130,7 +130,7 @@ public class AbstractID implements Comparable<AbstractID>, java.io.Serializable
// --------------------------------------------------------------------------------------------
// Standard Utilities
// --------------------------------------------------------------------------------------------
-
+
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -166,8 +166,8 @@ public class AbstractID implements Comparable<AbstractID>, java.io.Serializable
@Override
public int compareTo(AbstractID o) {
- int diff1 = (this.upperPart < o.upperPart) ? -1 : ((this.upperPart == o.upperPart) ? 0 : 1);
- int diff2 = (this.lowerPart < o.lowerPart) ? -1 : ((this.lowerPart == o.lowerPart) ? 0 : 1);
+ int diff1 = Long.compare(this.upperPart, o.upperPart);
+ int diff2 = Long.compare(this.lowerPart, o.lowerPart);
return diff1 == 0 ? diff2 : diff1;
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java b/flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java
index bd6847a..072d905 100644
--- a/flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java
@@ -23,6 +23,9 @@ import org.apache.flink.annotation.Internal;
import java.util.Collection;
import java.util.Map;
+/**
+ * Simple utility to work with Java collections.
+ */
@Internal
public final class CollectionUtil {
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/Collector.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/Collector.java b/flink-core/src/main/java/org/apache/flink/util/Collector.java
index 09f5c69..003459c 100644
--- a/flink-core/src/main/java/org/apache/flink/util/Collector.java
+++ b/flink-core/src/main/java/org/apache/flink/util/Collector.java
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.apache.flink.util;
import org.apache.flink.annotation.Public;
@@ -27,14 +26,14 @@ import org.apache.flink.annotation.Public;
*/
@Public
public interface Collector<T> {
-
+
/**
* Emits a record.
- *
+ *
* @param record The record to collect.
*/
void collect(T record);
-
+
/**
* Closes the collector. If any data was buffered, that data will be flushed.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java b/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java
index d18b9d3..c9d2234 100644
--- a/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java
+++ b/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java
@@ -22,10 +22,10 @@ import org.apache.flink.annotation.Public;
/**
* An exception that is thrown if the dynamic instantiation of code fails.
- *
+ *
* <p>This exception is supposed to "sum up" the zoo of exceptions typically thrown around
* dynamic code loading and instantiations:
- *
+ *
* <pre>{@code
* try {
* Class.forName(classname).asSubclass(TheType.class).newInstance();
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/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 6e0a9c6..5c69564 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
@@ -19,7 +19,7 @@
//
// The function "stringifyException" is based on source code from the Hadoop Project (http://hadoop.apache.org/),
// licensed by the Apache Software Foundation (ASF) under the Apache License, Version 2.0.
-// See the NOTICE file distributed with this work for additional information regarding copyright ownership.
+// See the NOTICE file distributed with this work for additional information regarding copyright ownership.
//
package org.apache.flink.util;
@@ -28,6 +28,7 @@ import org.apache.flink.annotation.Internal;
import org.apache.flink.util.function.RunnableWithException;
import javax.annotation.Nullable;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -43,15 +44,15 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
@Internal
public final class ExceptionUtils {
- /** The stringified representation of a null exception reference */
+ /** The stringified representation of a null exception reference. */
public static final String STRINGIFIED_NULL_EXCEPTION = "(null)";
/**
* Makes a string representation of the exception's stack trace, or "(null)", if the
* exception is null.
- *
- * This method makes a best effort and never fails.
- *
+ *
+ * <p>This method makes a best effort and never fails.
+ *
* @param e The exception to stringify.
* @return A string with exception name and call stack.
*/
@@ -59,7 +60,7 @@ public final class ExceptionUtils {
if (e == null) {
return STRINGIFIED_NULL_EXCEPTION;
}
-
+
try {
StringWriter stm = new StringWriter();
PrintWriter wrt = new PrintWriter(stm);
@@ -91,12 +92,12 @@ public final class ExceptionUtils {
/**
* Checks whether the given exception indicates a situation that may leave the
* JVM in a corrupted state, or an out-of-memory error.
- *
+ *
* <p>See {@link ExceptionUtils#isJvmFatalError(Throwable)} for a list of fatal JVM errors.
* This method additionally classifies the {@link OutOfMemoryError} as fatal, because it
* may occur in any thread (not the one that allocated the majority of the memory) and thus
* is often not recoverable by destroying the particular thread that threw the exception.
- *
+ *
* @param t The exception to check.
* @return True, if the exception is fatal to the JVM or and OutOfMemoryError, false otherwise.
*/
@@ -107,7 +108,7 @@ public final class ExceptionUtils {
/**
* Rethrows the given {@code Throwable}, if it represents an error that is fatal to the JVM.
* See {@link ExceptionUtils#isJvmFatalError(Throwable)} for a definition of fatal errors.
- *
+ *
* @param t The Throwable to check and rethrow.
*/
public static void rethrowIfFatalError(Throwable t) {
@@ -180,7 +181,7 @@ public final class ExceptionUtils {
* Throws the given {@code Throwable} in scenarios where the signatures do not allow you to
* throw an arbitrary Throwable. Errors and RuntimeExceptions are thrown directly, other exceptions
* are packed into runtime exceptions
- *
+ *
* @param t The throwable to be thrown.
*/
public static void rethrow(Throwable t) {
@@ -194,12 +195,12 @@ public final class ExceptionUtils {
throw new RuntimeException(t);
}
}
-
+
/**
* Throws the given {@code Throwable} in scenarios where the signatures do not allow you to
* throw an arbitrary Throwable. Errors and RuntimeExceptions are thrown directly, other exceptions
* are packed into a parent RuntimeException.
- *
+ *
* @param t The throwable to be thrown.
* @param parentMessage The message for the parent RuntimeException, if one is needed.
*/
@@ -257,10 +258,10 @@ public final class ExceptionUtils {
/**
* Re-throws the given {@code Throwable} in scenarios where the signatures allows only IOExceptions
* (and RuntimeException and Error).
- *
- * Throws this exception directly, if it is an IOException, a RuntimeException, or an Error. Otherwise it
+ *
+ * <p>Throws this exception directly, if it is an IOException, a RuntimeException, or an Error. Otherwise it
* wraps it in an IOException and throws it.
- *
+ *
* @param t The Throwable to be thrown.
*/
public static void rethrowIOException(Throwable t) throws IOException {
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/FileUtils.java b/flink-core/src/main/java/org/apache/flink/util/FileUtils.java
index a7afb43..6d15b2e 100644
--- a/flink-core/src/main/java/org/apache/flink/util/FileUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/util/FileUtils.java
@@ -39,7 +39,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
public final class FileUtils {
/** The alphabet to construct the random part of the filename from. */
- private static final char[] ALPHABET =
+ private static final char[] ALPHABET =
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f' };
/** The length of the random part of the filename. */
@@ -50,7 +50,7 @@ public final class FileUtils {
/**
* Constructs a random filename with the given prefix and
* a random part generated from hex characters.
- *
+ *
* @param prefix
* the prefix to the filename to be constructed
* @return the generated random filename with the given prefix
@@ -65,11 +65,11 @@ public final class FileUtils {
return stringBuilder.toString();
}
-
+
// ------------------------------------------------------------------------
// Simple reading and writing of files
// ------------------------------------------------------------------------
-
+
public static String readFile(File file, String charsetName) throws IOException {
byte[] bytes = Files.readAllBytes(file.toPath());
return new String(bytes, charsetName);
@@ -83,7 +83,7 @@ public final class FileUtils {
byte[] bytes = contents.getBytes(encoding);
Files.write(file.toPath(), bytes, StandardOpenOption.WRITE);
}
-
+
public static void writeFileUtf8(File file, String contents) throws IOException {
writeFile(file, contents, "UTF-8");
}
@@ -94,14 +94,14 @@ public final class FileUtils {
/**
* Removes the given file or directory recursively.
- *
+ *
* <p>If the file or directory does not exist, this does not throw an exception, but simply does nothing.
* It considers the fact that a file-to-be-deleted is not present a success.
- *
+ *
* <p>This method is safe against other concurrent deletion attempts.
- *
+ *
* @param file The file or directory to delete.
- *
+ *
* @throws IOException Thrown if the directory could not be cleaned for some reason, for example
* due to missing access/write permissions.
*/
@@ -125,12 +125,12 @@ public final class FileUtils {
/**
* Deletes the given directory recursively.
- *
+ *
* <p>If the directory does not exist, this does not throw an exception, but simply does nothing.
* It considers the fact that a directory-to-be-deleted is not present a success.
- *
+ *
* <p>This method is safe against other concurrent deletion attempts.
- *
+ *
* @param directory The directory to be deleted.
* @throws IOException Thrown if the given file is not a directory, or if the directory could not be
* deleted for some reason, for example due to missing access/write permissions.
@@ -171,10 +171,10 @@ public final class FileUtils {
/**
* Deletes the given directory recursively, not reporting any I/O exceptions
* that occur.
- *
+ *
* <p>This method is identical to {@link FileUtils#deleteDirectory(File)}, except that it
* swallows all exceptions and may leave the job quietly incomplete.
- *
+ *
* @param directory The directory to delete.
*/
public static void deleteDirectoryQuietly(File directory) {
@@ -189,12 +189,12 @@ public final class FileUtils {
}
/**
- * Removes all files contained within a directory, without removing the directory itself.
- *
+ * Removes all files contained within a directory, without removing the directory itself.
+ *
* <p>This method is safe against other concurrent deletion attempts.
- *
+ *
* @param directory The directory to remove all files from.
- *
+ *
* @throws FileNotFoundException Thrown if the directory itself does not exist.
* @throws IOException Thrown if the file indicates a proper file and not a directory, or if
* the directory could not be cleaned for some reason, for example
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/FlinkException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/FlinkException.java b/flink-core/src/main/java/org/apache/flink/util/FlinkException.java
index 550ab2c..9f34c93 100644
--- a/flink-core/src/main/java/org/apache/flink/util/FlinkException.java
+++ b/flink-core/src/main/java/org/apache/flink/util/FlinkException.java
@@ -30,7 +30,7 @@ public class FlinkException extends Exception {
/**
* Creates a new Exception with the given message and null as the cause.
- *
+ *
* @param message The exception message
*/
public FlinkException(String message) {
@@ -39,7 +39,7 @@ public class FlinkException extends Exception {
/**
* Creates a new exception with a null message and the given cause.
- *
+ *
* @param cause The exception that caused this exception
*/
public FlinkException(Throwable cause) {
@@ -47,8 +47,8 @@ public class FlinkException extends Exception {
}
/**
- * Creates a new exception with the given message and cause
- *
+ * Creates a new exception with the given message and cause.
+ *
* @param message The exception message
* @param cause The exception that caused this exception
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java b/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java
index 16b783b..cfee197 100644
--- a/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java
+++ b/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java
@@ -30,7 +30,7 @@ public class FlinkRuntimeException extends RuntimeException {
/**
* Creates a new Exception with the given message and null as the cause.
- *
+ *
* @param message The exception message
*/
public FlinkRuntimeException(String message) {
@@ -39,7 +39,7 @@ public class FlinkRuntimeException extends RuntimeException {
/**
* Creates a new exception with a null message and the given cause.
- *
+ *
* @param cause The exception that caused this exception
*/
public FlinkRuntimeException(Throwable cause) {
@@ -47,8 +47,8 @@ public class FlinkRuntimeException extends RuntimeException {
}
/**
- * Creates a new exception with the given message and cause
- *
+ * Creates a new exception with the given message and cause.
+ *
* @param message The exception message
* @param cause The exception that caused this exception
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/FutureUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/FutureUtil.java b/flink-core/src/main/java/org/apache/flink/util/FutureUtil.java
index 5ecf344..b6bac88 100644
--- a/flink-core/src/main/java/org/apache/flink/util/FutureUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/FutureUtil.java
@@ -23,6 +23,9 @@ import org.apache.flink.annotation.Internal;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RunnableFuture;
+/**
+ * Simple utility class to work with Java's Futures.
+ */
@Internal
public class FutureUtil {
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/IOUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/IOUtils.java b/flink-core/src/main/java/org/apache/flink/util/IOUtils.java
index 0bdc13a..498c899 100644
--- a/flink-core/src/main/java/org/apache/flink/util/IOUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/util/IOUtils.java
@@ -28,20 +28,19 @@ import java.net.Socket;
/**
* An utility class for I/O related functionality.
- *
*/
public final class IOUtils {
/** The block size for byte operations in byte. */
private static final int BLOCKSIZE = 4096;
-
+
// ------------------------------------------------------------------------
// Byte copy operations
// ------------------------------------------------------------------------
/**
* Copies from one stream to another.
- *
+ *
* @param in
* InputStream to read from
* @param out
@@ -80,7 +79,7 @@ public final class IOUtils {
/**
* Copies from one stream to another. <strong>closes the input and output
* streams at the end</strong>.
- *
+ *
* @param in
* InputStream to read from
* @param out
@@ -94,7 +93,7 @@ public final class IOUtils {
/**
* Copies from one stream to another.
- *
+ *
* @param in
* InputStream to read from
* @param out
@@ -112,10 +111,10 @@ public final class IOUtils {
// ------------------------------------------------------------------------
// Stream input skipping
// ------------------------------------------------------------------------
-
+
/**
* Reads len bytes in a loop.
- *
+ *
* @param in
* The InputStream to read from
* @param buf
@@ -142,7 +141,7 @@ public final class IOUtils {
/**
* Similar to readFully(). Skips bytes in a loop.
- *
+ *
* @param in
* The InputStream to skip bytes from
* @param len
@@ -163,11 +162,11 @@ public final class IOUtils {
// ------------------------------------------------------------------------
// Silent I/O cleanup / closing
// ------------------------------------------------------------------------
-
+
/**
* Close the AutoCloseable objects and <b>ignore</b> any {@link Exception} or
* null pointers. Must only be used for cleanup in exception handlers.
- *
+ *
* @param log
* the log to record problems to at debug level. Can be <code>null</code>.
* @param closeables
@@ -190,7 +189,7 @@ public final class IOUtils {
/**
* Closes the stream ignoring {@link IOException}. Must only be called in
* cleaning up from exception handlers.
- *
+ *
* @param stream
* the stream to close
*/
@@ -200,7 +199,7 @@ public final class IOUtils {
/**
* Closes the socket ignoring {@link IOException}.
- *
+ *
* @param sock
* the socket to close
*/
@@ -254,6 +253,8 @@ public final class IOUtils {
}
/**
+ * Closes the given AutoCloseable.
+ *
* <p><b>Important:</b> This method is expected to never throw an exception.
*/
public static void closeQuietly(AutoCloseable closeable) {
@@ -263,7 +264,7 @@ public final class IOUtils {
}
} catch (Throwable ignored) {}
}
-
+
// ------------------------------------------------------------------------
/**
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java b/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
index 6441c86..4bfec2e 100644
--- a/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
@@ -43,7 +43,7 @@ import java.util.HashMap;
*/
@Internal
public final class InstantiationUtil {
-
+
/**
* A custom ObjectInputStream that can load classes using a specific ClassLoader.
*/
@@ -77,11 +77,11 @@ public final class InstantiationUtil {
return super.resolveClass(desc);
}
-
+
// ------------------------------------------------
private static final HashMap<String, Class<?>> primitiveClasses = new HashMap<>(9);
-
+
static {
primitiveClasses.put("boolean", boolean.class);
primitiveClasses.put("byte", byte.class);
@@ -94,17 +94,17 @@ public final class InstantiationUtil {
primitiveClasses.put("void", void.class);
}
}
-
-
+
+
/**
* Creates a new instance of the given class.
- *
+ *
* @param <T> The generic type of the class.
* @param clazz The class to instantiate.
* @param castTo Optional parameter, specifying the class that the given class must be a subclass off. This
- * argument is added to prevent class cast exceptions occurring later.
+ * argument is added to prevent class cast exceptions occurring later.
* @return An instance of the given class.
- *
+ *
* @throws RuntimeException Thrown, if the class could not be instantiated. The exception contains a detailed
* message about the reason why the instantiation failed.
*/
@@ -112,24 +112,24 @@ public final class InstantiationUtil {
if (clazz == null) {
throw new NullPointerException();
}
-
+
// check if the class is a subclass, if the check is required
if (castTo != null && !castTo.isAssignableFrom(clazz)) {
- throw new RuntimeException("The class '" + clazz.getName() + "' is not a subclass of '" +
+ throw new RuntimeException("The class '" + clazz.getName() + "' is not a subclass of '" +
castTo.getName() + "' as is required.");
}
-
+
return instantiate(clazz);
}
/**
* Creates a new instance of the given class.
- *
+ *
* @param <T> The generic type of the class.
* @param clazz The class to instantiate.
* @return An instance of the given class.
- *
+ *
* @throws RuntimeException Thrown, if the class could not be instantiated. The exception contains a detailed
* message about the reason why the instantiation failed.
*/
@@ -137,7 +137,7 @@ public final class InstantiationUtil {
if (clazz == null) {
throw new NullPointerException();
}
-
+
// try to instantiate the class
try {
return clazz.newInstance();
@@ -145,23 +145,23 @@ public final class InstantiationUtil {
catch (InstantiationException | IllegalAccessException iex) {
// check for the common problem causes
checkForInstantiation(clazz);
-
+
// here we are, if non of the common causes was the problem. then the error was
// most likely an exception in the constructor or field initialization
- throw new RuntimeException("Could not instantiate type '" + clazz.getName() +
+ throw new RuntimeException("Could not instantiate type '" + clazz.getName() +
"' due to an unspecified exception: " + iex.getMessage(), iex);
}
catch (Throwable t) {
String message = t.getMessage();
- throw new RuntimeException("Could not instantiate type '" + clazz.getName() +
- "' Most likely the constructor (or a member variable initialization) threw an exception" +
+ throw new RuntimeException("Could not instantiate type '" + clazz.getName() +
+ "' Most likely the constructor (or a member variable initialization) threw an exception" +
(message == null ? "." : ": " + message), t);
}
}
-
+
/**
* Checks, whether the given class has a public nullary constructor.
- *
+ *
* @param clazz The class to check.
* @return True, if the class has a public nullary constructor, false if not.
*/
@@ -175,20 +175,20 @@ public final class InstantiationUtil {
}
return false;
}
-
+
/**
* Checks, whether the given class is public.
- *
+ *
* @param clazz The class to check.
* @return True, if the class is public, false if not.
*/
public static boolean isPublic(Class<?> clazz) {
return Modifier.isPublic(clazz.getModifiers());
}
-
+
/**
* Checks, whether the class is a proper class, i.e. not abstract or an interface, and not a primitive type.
- *
+ *
* @param clazz The class to check.
* @return True, if the class is a proper class, false otherwise.
*/
@@ -200,29 +200,29 @@ public final class InstantiationUtil {
/**
* Checks, whether the class is an inner class that is not statically accessible. That is especially true for
* anonymous inner classes.
- *
+ *
* @param clazz The class to check.
* @return True, if the class is a non-statically accessible inner class.
*/
public static boolean isNonStaticInnerClass(Class<?> clazz) {
- return clazz.getEnclosingClass() != null &&
+ return clazz.getEnclosingClass() != null &&
(clazz.getDeclaringClass() == null || !Modifier.isStatic(clazz.getModifiers()));
}
-
+
/**
* Performs a standard check whether the class can be instantiated by {@code Class#newInstance()}.
- *
+ *
* @param clazz The class to check.
* @throws RuntimeException Thrown, if the class cannot be instantiated by {@code Class#newInstance()}.
*/
public static void checkForInstantiation(Class<?> clazz) {
final String errorMessage = checkForInstantiationError(clazz);
-
+
if (errorMessage != null) {
throw new RuntimeException("The class '" + clazz.getName() + "' is not instantiable: " + errorMessage);
}
}
-
+
public static String checkForInstantiationError(Class<?> clazz) {
if (!isPublic(clazz)) {
return "The class is not public.";
@@ -235,19 +235,19 @@ public final class InstantiationUtil {
} else if (!hasPublicNullaryConstructor(clazz)) {
return "The class has no (implicit) public nullary constructor, i.e. a constructor without arguments.";
} else {
- return null;
+ return null;
}
}
-
+
public static <T> T readObjectFromConfig(Configuration config, String key, ClassLoader cl) throws IOException, ClassNotFoundException {
byte[] bytes = config.getBytes(key, null);
if (bytes == null) {
return null;
}
-
+
return deserializeObject(bytes, cl);
}
-
+
public static void writeObjectToConfig(Object o, Configuration config, String key) throws IOException {
byte[] bytes = serializeObject(o);
config.setBytes(key, bytes);
@@ -281,7 +281,7 @@ public final class InstantiationUtil {
DataInputViewStreamWrapper inputViewWrapper = new DataInputViewStreamWrapper(new ByteArrayInputStream(buf));
return serializer.deserialize(reuse, inputViewWrapper);
}
-
+
@SuppressWarnings("unchecked")
public static <T> T deserializeObject(byte[] bytes, ClassLoader cl) throws IOException, ClassNotFoundException {
final ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -338,9 +338,11 @@ public final class InstantiationUtil {
*
* @param obj Object to clone
* @param <T> Type of the object to clone
- * @return Cloned object
- * @throws IOException
- * @throws ClassNotFoundException
+ * @return The cloned object
+ *
+ * @throws IOException Thrown if the serialization or deserialization process fails.
+ * @throws ClassNotFoundException Thrown if any of the classes referenced by the object
+ * cannot be resolved during deserialization.
*/
public static <T extends Serializable> T clone(T obj) throws IOException, ClassNotFoundException {
if (obj == null) {
@@ -357,11 +359,12 @@ public final class InstantiationUtil {
* @param obj Object to clone
* @param classLoader The classloader to resolve the classes during deserialization.
* @param <T> Type of the object to clone
- *
+ *
* @return Cloned object
- *
- * @throws IOException
- * @throws ClassNotFoundException
+ *
+ * @throws IOException Thrown if the serialization or deserialization process fails.
+ * @throws ClassNotFoundException Thrown if any of the classes referenced by the object
+ * cannot be resolved during deserialization.
*/
public static <T extends Serializable> T clone(T obj, ClassLoader classLoader) throws IOException, ClassNotFoundException {
if (obj == null) {
@@ -399,10 +402,10 @@ public final class InstantiationUtil {
return copy;
}
}
-
-
+
+
// --------------------------------------------------------------------------------------------
-
+
/**
* Private constructor to prevent instantiation.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/IterableIterator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/IterableIterator.java b/flink-core/src/main/java/org/apache/flink/util/IterableIterator.java
index f66bab9..322459f 100644
--- a/flink-core/src/main/java/org/apache/flink/util/IterableIterator.java
+++ b/flink-core/src/main/java/org/apache/flink/util/IterableIterator.java
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.apache.flink.util;
import org.apache.flink.annotation.Internal;
@@ -25,7 +24,7 @@ import java.util.Iterator;
/**
* An {@link Iterator} that is also {@link Iterable} (often by returning itself).
- *
+ *
* @param <E> The iterated elements' type.
*/
@Internal
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java b/flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java
index 86a8ce6..7c9fea7 100644
--- a/flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java
+++ b/flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java
@@ -33,13 +33,13 @@ public class LongValueSequenceIterator extends SplittableIterator<LongValue> {
private static final long serialVersionUID = 1L;
- /** The last number returned by the iterator */
+ /** The last number returned by the iterator. */
private final long to;
- /** The next number to be returned */
+ /** The next number to be returned. */
private long current;
- /** The next value to be returned */
+ /** The next value to be returned. */
private LongValue currentValue = new LongValue();
/**
@@ -125,7 +125,7 @@ public class LongValueSequenceIterator extends SplittableIterator<LongValue> {
if (current == Long.MIN_VALUE) {
// this means to >= 0
- halfDiff = (Long.MAX_VALUE/2+1) + to/2;
+ halfDiff = (Long.MAX_VALUE / 2 + 1) + to / 2;
} else {
long posFrom = -current;
if (posFrom > to) {
@@ -156,12 +156,12 @@ public class LongValueSequenceIterator extends SplittableIterator<LongValue> {
int i = 0;
for (; i < numWithExtra; i++) {
long next = curr + elementsPerSplit + 1;
- iters[i] = new LongValueSequenceIterator(curr, next-1);
+ iters[i] = new LongValueSequenceIterator(curr, next - 1);
curr = next;
}
for (; i < numPartitions; i++) {
long next = curr + elementsPerSplit;
- iters[i] = new LongValueSequenceIterator(curr, next-1, true);
+ iters[i] = new LongValueSequenceIterator(curr, next - 1, true);
curr = next;
}
@@ -180,14 +180,13 @@ public class LongValueSequenceIterator extends SplittableIterator<LongValue> {
}
}
-
@Override
public int getMaximumNumberOfSplits() {
- if (to >= Integer.MAX_VALUE || current <= Integer.MIN_VALUE || to-current+1 >= Integer.MAX_VALUE) {
+ if (to >= Integer.MAX_VALUE || current <= Integer.MIN_VALUE || to - current + 1 >= Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
else {
- return (int) (to-current+1);
+ return (int) (to - current + 1);
}
}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/MathUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/MathUtils.java b/flink-core/src/main/java/org/apache/flink/util/MathUtils.java
index 1d84a39..48c32a3 100644
--- a/flink-core/src/main/java/org/apache/flink/util/MathUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/util/MathUtils.java
@@ -22,13 +22,13 @@ package org.apache.flink.util;
* Collection of simple mathematical routines.
*/
public final class MathUtils {
-
+
/**
* Computes the logarithm of the given value to the base of 2, rounded down. It corresponds to the
* position of the highest non-zero bit. The position is counted, starting with 0 from the least
* significant bit to the most significant bit. For example, <code>log2floor(16) = 4</code>, and
* <code>log2floor(10) = 3</code>.
- *
+ *
* @param value The value to compute the logarithm for.
* @return The logarithm (rounded down) to the base of 2.
* @throws ArithmeticException Thrown, if the given value is zero.
@@ -40,11 +40,11 @@ public final class MathUtils {
return 31 - Integer.numberOfLeadingZeros(value);
}
-
+
/**
* Computes the logarithm of the given value to the base of 2. This method throws an error,
* if the given argument is not a power of 2.
- *
+ *
* @param value The value to compute the logarithm for.
* @return The logarithm to the base of 2.
* @throws ArithmeticException Thrown, if the given value is zero.
@@ -59,25 +59,25 @@ public final class MathUtils {
}
return 31 - Integer.numberOfLeadingZeros(value);
}
-
+
/**
* Decrements the given number down to the closest power of two. If the argument is a
* power of two, it remains unchanged.
- *
+ *
* @param value The value to round down.
* @return The closest value that is a power of two and less or equal than the given value.
*/
public static int roundDownToPowerOf2(int value) {
return Integer.highestOneBit(value);
}
-
+
/**
* Casts the given value to a 32 bit integer, if it can be safely done. If the cast would change the numeric
* value, this method raises an exception.
- * <p>
- * This method is a protection in places where one expects to be able to safely case, but where unexpected
+ *
+ * <p>This method is a protection in places where one expects to be able to safely case, but where unexpected
* situations could make the cast unsafe and would cause hidden problems that are hard to track down.
- *
+ *
* @param value The value to be cast to an integer.
* @return The given value as an integer.
* @see Math#toIntExact(long)
@@ -106,7 +106,7 @@ public final class MathUtils {
* The hash function has the <i>full avalanche</i> property, meaning that every bit of the value to be hashed
* affects every bit of the hash value.
*
- * It is crucial to use different hash functions to partition data across machines and the internal partitioning of
+ * <p>It is crucial to use different hash functions to partition data across machines and the internal partitioning of
* data structures. This hash function is intended for partitioning internally in data structures.
*
* @param code The integer to be hashed.
@@ -125,7 +125,7 @@ public final class MathUtils {
/**
* This function hashes an integer value.
*
- * It is crucial to use different hash functions to partition data across machines and the internal partitioning of
+ * <p>It is crucial to use different hash functions to partition data across machines and the internal partitioning of
* data structures. This hash function is intended for partitioning across machines.
*
* @param code The integer to be hashed.
@@ -154,7 +154,7 @@ public final class MathUtils {
}
/**
- * Round the given number to the next power of two
+ * Round the given number to the next power of two.
* @param x number to round
* @return x rounded up to the next power of two
*/
@@ -198,7 +198,7 @@ public final class MathUtils {
}
// ============================================================================================
-
+
/**
* Prevent Instantiation through private constructor.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/MutableObjectIterator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/MutableObjectIterator.java b/flink-core/src/main/java/org/apache/flink/util/MutableObjectIterator.java
index 9273330..99b9644 100644
--- a/flink-core/src/main/java/org/apache/flink/util/MutableObjectIterator.java
+++ b/flink-core/src/main/java/org/apache/flink/util/MutableObjectIterator.java
@@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.flink.util;
import org.apache.flink.annotation.Internal;
@@ -23,7 +24,7 @@ import java.io.IOException;
/**
* A simple iterator interface. The key differences to the {@link java.util.Iterator} are
- *
+ *
* <ul>
* <li>It has two distinct <code>next()</code>, where one variant allows to pass an object that may
* be reused, if the type is mutable.</li>
@@ -31,23 +32,23 @@ import java.io.IOException;
* splitting it over two different functions such as <code>hasNext()</code> and <code>next()</code>
* </li>
* </ul>
- *
+ *
* @param <E> The element type of the collection iterated over.
*/
@Internal
public interface MutableObjectIterator<E> {
-
+
/**
* Gets the next element from the collection. The contents of that next element is put into the
* given reuse object, if the type is mutable.
- *
+ *
* @param reuse The target object into which to place next element if E is mutable.
* @return The filled object or <code>null</code> if the iterator is exhausted.
- *
- * @throws IOException Thrown, if a problem occurred in the underlying I/O layer or in the
+ *
+ * @throws IOException Thrown, if a problem occurred in the underlying I/O layer or in the
* serialization / deserialization logic
*/
- public E next(E reuse) throws IOException;
+ E next(E reuse) throws IOException;
/**
* Gets the next element from the collection. The iterator implementation
@@ -58,5 +59,5 @@ public interface MutableObjectIterator<E> {
* @throws IOException Thrown, if a problem occurred in the underlying I/O layer or in the
* serialization / deserialization logic
*/
- public E next() throws IOException;
+ E next() throws IOException;
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/NetUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/NetUtils.java b/flink-core/src/main/java/org/apache/flink/util/NetUtils.java
index f56b452..447e8a9 100644
--- a/flink-core/src/main/java/org/apache/flink/util/NetUtils.java
+++ b/flink-core/src/main/java/org/apache/flink/util/NetUtils.java
@@ -19,8 +19,8 @@
package org.apache.flink.util;
import org.apache.flink.annotation.Internal;
-
import org.apache.flink.configuration.IllegalConfigurationException;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.net.util.IPAddressUtil;
@@ -38,18 +38,21 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
+/**
+ * Utility for various network related tasks (such as finding free ports).
+ */
@Internal
public class NetUtils {
private static final Logger LOG = LoggerFactory.getLogger(NetUtils.class);
- /** The wildcard address to listen on all interfaces (either 0.0.0.0 or ::) */
+ /** The wildcard address to listen on all interfaces (either 0.0.0.0 or ::). */
private static final String WILDCARD_ADDRESS = new InetSocketAddress(0).getAddress().getHostAddress();
-
+
/**
* Turn a fully qualified domain name (fqdn) into a hostname. If the fqdn has multiple subparts
* (separated by a period '.'), it will take the first part. Otherwise it takes the entire fqdn.
- *
+ *
* @param fqdn The fully qualified domain name.
* @return The hostname.
*/
@@ -58,7 +61,7 @@ public class NetUtils {
throw new IllegalArgumentException("fqdn is null");
}
int dotPos = fqdn.indexOf('.');
- if(dotPos == -1) {
+ if (dotPos == -1) {
return fqdn;
} else {
return fqdn.substring(0, dotPos);
@@ -68,31 +71,31 @@ public class NetUtils {
/**
* Method to validate if the given String represents a hostname:port.
*
- * Works also for ipv6.
+ * <p>Works also for ipv6.
*
- * See: http://stackoverflow.com/questions/2345063/java-common-way-to-validate-and-convert-hostport-to-inetsocketaddress
+ * <p>See: http://stackoverflow.com/questions/2345063/java-common-way-to-validate-and-convert-hostport-to-inetsocketaddress
*
* @return URL object for accessing host and Port
*/
public static URL getCorrectHostnamePort(String hostPort) {
try {
- URL u = new URL("http://"+hostPort);
- if(u.getHost() == null) {
- throw new IllegalArgumentException("The given host:port ('"+hostPort+"') doesn't contain a valid host");
+ URL u = new URL("http://" + hostPort);
+ if (u.getHost() == null) {
+ throw new IllegalArgumentException("The given host:port ('" + hostPort + "') doesn't contain a valid host");
}
- if(u.getPort() == -1) {
- throw new IllegalArgumentException("The given host:port ('"+hostPort+"') doesn't contain a valid port");
+ if (u.getPort() == -1) {
+ throw new IllegalArgumentException("The given host:port ('" + hostPort + "') doesn't contain a valid port");
}
return u;
} catch (MalformedURLException e) {
- throw new IllegalArgumentException("The given host:port ('"+hostPort+"') is invalid", e);
+ throw new IllegalArgumentException("The given host:port ('" + hostPort + "') is invalid", e);
}
}
// ------------------------------------------------------------------------
// Lookup of to free ports
// ------------------------------------------------------------------------
-
+
/**
* Find a non-occupied port.
*
@@ -111,7 +114,7 @@ public class NetUtils {
throw new RuntimeException("Could not find a free permitted port on the machine.");
}
-
+
// ------------------------------------------------------------------------
// Encoding of IP addresses for URLs
@@ -168,7 +171,7 @@ public class NetUtils {
/**
* Encodes an IP address properly as a URL string. This method makes sure that IPv6 addresses
* have the proper formatting to be included in URLs.
- *
+ *
* @param address The IP address to encode.
* @return The proper URL string encoded IP address.
*/
@@ -202,7 +205,7 @@ public class NetUtils {
/**
* Encodes an IP address and port to be included in URL. in particular, this method makes
* sure that IPv6 addresses have the proper formatting to be included in URLs.
- *
+ *
* @param address The socket address with the IP address and port.
* @return The proper URL string encoded IP address and port.
*/
@@ -214,7 +217,7 @@ public class NetUtils {
}
/**
- * Normalizes and encodes a hostname and port to be included in URL.
+ * Normalizes and encodes a hostname and port to be included in URL.
* In particular, this method makes sure that IPv6 address literals have the proper
* formatting to be included in URLs.
*
@@ -277,7 +280,7 @@ public class NetUtils {
// convert into text form
StringBuilder buf = new StringBuilder(40);
buf.append('[');
-
+
boolean lastWasNumber = false;
for (int i = 0; i < hextets.length; i++) {
boolean thisIsNumber = hextets[i] >= 0;
@@ -296,11 +299,11 @@ public class NetUtils {
buf.append(']');
return buf.toString();
}
-
+
// ------------------------------------------------------------------------
// Port range parsing
// ------------------------------------------------------------------------
-
+
/**
* Returns an iterator over available ports defined by the range definition.
*
@@ -310,9 +313,9 @@ public class NetUtils {
*/
public static Iterator<Integer> getPortRangeFromString(String rangeDefinition) throws NumberFormatException {
final String[] ranges = rangeDefinition.trim().split(",");
-
+
UnionIterator<Integer> iterators = new UnionIterator<>();
-
+
for (String rawRange: ranges) {
Iterator<Integer> rangeIterator;
String range = rawRange.trim();
@@ -332,7 +335,7 @@ public class NetUtils {
throw new IllegalConfigurationException("Invalid port configuration. Port must be between 0" +
"and 65535, but was " + start + ".");
}
- final int end = Integer.valueOf(range.substring(dashIdx+1, range.length()));
+ final int end = Integer.valueOf(range.substring(dashIdx + 1, range.length()));
if (end < 0 || end > 65535) {
throw new IllegalConfigurationException("Invalid port configuration. Port must be between 0" +
"and 65535, but was " + end + ".");
@@ -357,7 +360,7 @@ public class NetUtils {
}
iterators.add(rangeIterator);
}
-
+
return iterators;
}
@@ -393,6 +396,10 @@ public class NetUtils {
return WILDCARD_ADDRESS;
}
+ /**
+ * A factory for a local socket from port number.
+ */
+ @FunctionalInterface
public interface SocketFactory {
ServerSocket createSocket(int port) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java b/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java
index f9b02f3..b7377ec 100644
--- a/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java
+++ b/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java
@@ -29,20 +29,20 @@ import java.util.NoSuchElementException;
*/
@Public
public class NumberSequenceIterator extends SplittableIterator<Long> {
-
+
private static final long serialVersionUID = 1L;
- /** The last number returned by the iterator */
+ /** The last number returned by the iterator. */
private final long to;
-
- /** The next number to be returned */
+
+ /** The next number to be returned. */
private long current;
-
-
+
+
/**
* Creates a new splittable iterator, returning the range [from, to].
* Both boundaries of the interval are inclusive.
- *
+ *
* @param from The first number returned by the iterator.
* @param to The last number returned by the iterator.
*/
@@ -50,15 +50,15 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
if (from > to) {
throw new IllegalArgumentException("The 'to' value must not be smaller than the 'from' value.");
}
-
+
this.current = from;
this.to = to;
}
-
-
+
+
/**
* Internal constructor to allow for empty iterators.
- *
+ *
* @param from The first number returned by the iterator.
* @param to The last number returned by the iterator.
* @param unused A dummy parameter to disambiguate the constructor.
@@ -67,11 +67,11 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
this.current = from;
this.to = to;
}
-
+
public long getCurrent() {
return this.current;
}
-
+
public long getTo() {
return this.to;
}
@@ -100,15 +100,15 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
if (numPartitions < 1) {
throw new IllegalArgumentException("The number of partitions must be at least 1.");
}
-
+
if (numPartitions == 1) {
return new NumberSequenceIterator[] { new NumberSequenceIterator(current, to) };
}
-
+
// here, numPartitions >= 2 !!!
-
+
long elementsPerSplit;
-
+
if (to - current + 1 >= 0) {
elementsPerSplit = (to - current + 1) / numPartitions;
}
@@ -118,10 +118,10 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
// in most cases it holds that: current < 0 and to > 0, except for: to == 0 and current == Long.MIN_VALUE
// the later needs a special case
final long halfDiff; // must be positive
-
+
if (current == Long.MIN_VALUE) {
// this means to >= 0
- halfDiff = (Long.MAX_VALUE/2+1) + to/2;
+ halfDiff = (Long.MAX_VALUE / 2 + 1) + to / 2;
} else {
long posFrom = -current;
if (posFrom > to) {
@@ -132,35 +132,35 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
}
elementsPerSplit = halfDiff / numPartitions * 2;
}
-
+
if (elementsPerSplit < Long.MAX_VALUE) {
// figure out how many get one in addition
long numWithExtra = -(elementsPerSplit * numPartitions) + to - current + 1;
-
+
// based on rounding errors, we may have lost one)
if (numWithExtra > numPartitions) {
elementsPerSplit++;
numWithExtra -= numPartitions;
-
+
if (numWithExtra > numPartitions) {
throw new RuntimeException("Bug in splitting logic. To much rounding loss.");
}
}
-
+
NumberSequenceIterator[] iters = new NumberSequenceIterator[numPartitions];
long curr = current;
int i = 0;
for (; i < numWithExtra; i++) {
long next = curr + elementsPerSplit + 1;
- iters[i] = new NumberSequenceIterator(curr, next-1);
+ iters[i] = new NumberSequenceIterator(curr, next - 1);
curr = next;
}
for (; i < numPartitions; i++) {
long next = curr + elementsPerSplit;
- iters[i] = new NumberSequenceIterator(curr, next-1, true);
+ iters[i] = new NumberSequenceIterator(curr, next - 1, true);
curr = next;
}
-
+
return iters;
}
else {
@@ -168,22 +168,21 @@ public class NumberSequenceIterator extends SplittableIterator<Long> {
if (numPartitions != 2) {
throw new RuntimeException("Bug in splitting logic.");
}
-
+
return new NumberSequenceIterator[] {
new NumberSequenceIterator(current, current + elementsPerSplit),
new NumberSequenceIterator(current + elementsPerSplit, to)
};
}
}
-
@Override
public int getMaximumNumberOfSplits() {
- if (to >= Integer.MAX_VALUE || current <= Integer.MIN_VALUE || to-current+1 >= Integer.MAX_VALUE) {
+ if (to >= Integer.MAX_VALUE || current <= Integer.MIN_VALUE || to - current + 1 >= Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
else {
- return (int) (to-current+1);
+ return (int) (to - current + 1);
}
}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/OperatingSystem.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/OperatingSystem.java b/flink-core/src/main/java/org/apache/flink/util/OperatingSystem.java
index 7c477cc..efa7bf6 100644
--- a/flink-core/src/main/java/org/apache/flink/util/OperatingSystem.java
+++ b/flink-core/src/main/java/org/apache/flink/util/OperatingSystem.java
@@ -25,29 +25,29 @@ import org.apache.flink.annotation.Internal;
*/
@Internal
public enum OperatingSystem {
-
+
LINUX,
WINDOWS,
MAC_OS,
FREE_BSD,
SOLARIS,
UNKNOWN;
-
+
// ------------------------------------------------------------------------
-
+
/**
* Gets the operating system that the JVM runs on from the java system properties.
* this method returns <tt>UNKNOWN</tt>, if the operating system was not successfully determined.
- *
+ *
* @return The enum constant for the operating system, or <tt>UNKNOWN</tt>, if it was not possible to determine.
*/
public static OperatingSystem getCurrentOperatingSystem() {
return os;
}
-
+
/**
* Checks whether the operating system this JVM runs on is Windows.
- *
+ *
* @return <code>true</code> if the operating system this JVM runs on is
* Windows, <code>false</code> otherwise
*/
@@ -57,7 +57,7 @@ public enum OperatingSystem {
/**
* Checks whether the operating system this JVM runs on is Linux.
- *
+ *
* @return <code>true</code> if the operating system this JVM runs on is
* Linux, <code>false</code> otherwise
*/
@@ -67,7 +67,7 @@ public enum OperatingSystem {
/**
* Checks whether the operating system this JVM runs on is Windows.
- *
+ *
* @return <code>true</code> if the operating system this JVM runs on is
* Windows, <code>false</code> otherwise
*/
@@ -77,7 +77,7 @@ public enum OperatingSystem {
/**
* Checks whether the operating system this JVM runs on is FreeBSD.
- *
+ *
* @return <code>true</code> if the operating system this JVM runs on is
* FreeBSD, <code>false</code> otherwise
*/
@@ -94,21 +94,21 @@ public enum OperatingSystem {
public static boolean isSolaris() {
return getCurrentOperatingSystem() == SOLARIS;
}
-
+
/**
* The enum constant for the operating system.
*/
private static final OperatingSystem os = readOSFromSystemProperties();
-
+
/**
* Parses the operating system that the JVM runs on from the java system properties.
* If the operating system was not successfully determined, this method returns {@code UNKNOWN}.
- *
+ *
* @return The enum constant for the operating system, or {@code UNKNOWN}, if it was not possible to determine.
*/
private static OperatingSystem readOSFromSystemProperties() {
String osName = System.getProperty(OS_KEY);
-
+
if (osName.startsWith(LINUX_OS_PREFIX)) {
return LINUX;
}
@@ -125,14 +125,14 @@ public enum OperatingSystem {
if (osNameLowerCase.contains(SOLARIS_OS_INFIX_1) || osNameLowerCase.contains(SOLARIS_OS_INFIX_2)) {
return SOLARIS;
}
-
+
return UNKNOWN;
}
-
+
// --------------------------------------------------------------------------------------------
- // Constants to extract the OS type from the java environment
+ // Constants to extract the OS type from the java environment
// --------------------------------------------------------------------------------------------
-
+
/**
* The key to extract the operating system name from the system properties.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/OutputTag.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/OutputTag.java b/flink-core/src/main/java/org/apache/flink/util/OutputTag.java
index 800c0b5..f132cb3 100644
--- a/flink-core/src/main/java/org/apache/flink/util/OutputTag.java
+++ b/flink-core/src/main/java/org/apache/flink/util/OutputTag.java
@@ -15,17 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.flink.util;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
+package org.apache.flink.util;
import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.api.common.functions.InvalidTypesException;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
/**
* An {@link OutputTag} is a typed and named tag to use for tagging side outputs
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/Preconditions.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/Preconditions.java b/flink-core/src/main/java/org/apache/flink/util/Preconditions.java
index e970c13..612a6e3 100644
--- a/flink-core/src/main/java/org/apache/flink/util/Preconditions.java
+++ b/flink-core/src/main/java/org/apache/flink/util/Preconditions.java
@@ -32,7 +32,7 @@ import javax.annotation.Nullable;
/**
* A collection of static utility methods to validate input.
- *
+ *
* <p>This class is modelled after Google Guava's Preconditions class, and partly takes code
* from that class. We add this code to the Flink code base in order to reduce external
* dependencies.
@@ -43,14 +43,14 @@ public final class Preconditions {
// ------------------------------------------------------------------------
// Null checks
// ------------------------------------------------------------------------
-
+
/**
* Ensures that the given object reference is not null.
* Upon violation, a {@code NullPointerException} with no message is thrown.
- *
+ *
* @param reference The object reference
* @return The object reference itself (generically typed).
- *
+ *
* @throws NullPointerException Thrown, if the passed reference was null.
*/
public static <T> T checkNotNull(T reference) {
@@ -59,11 +59,11 @@ public final class Preconditions {
}
return reference;
}
-
+
/**
* Ensures that the given object reference is not null.
* Upon violation, a {@code NullPointerException} with the given message is thrown.
- *
+ *
* @param reference The object reference
* @param errorMessage The message for the {@code NullPointerException} that is thrown if the check fails.
* @return The object reference itself (generically typed).
@@ -80,7 +80,7 @@ public final class Preconditions {
/**
* Ensures that the given object reference is not null.
* Upon violation, a {@code NullPointerException} with the given message is thrown.
- *
+ *
* <p>The error message is constructed from a template and an arguments array, after
* a similar fashion as {@link String#format(String, Object...)}, but supporting only
* {@code %s} as a placeholder.
@@ -91,7 +91,7 @@ public final class Preconditions {
* {@code %s} placeholders with the error message arguments.
* @param errorMessageArgs The arguments for the error message, to be inserted into the
* message template for the {@code %s} placeholders.
- *
+ *
* @return The object reference itself (generically typed).
*
* @throws NullPointerException Thrown, if the passed reference was null.
@@ -99,7 +99,7 @@ public final class Preconditions {
public static <T> T checkNotNull(T reference,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
-
+
if (reference == null) {
throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));
}
@@ -109,13 +109,13 @@ public final class Preconditions {
// ------------------------------------------------------------------------
// Boolean Condition Checking (Argument)
// ------------------------------------------------------------------------
-
+
/**
* Checks the given boolean condition, and throws an {@code IllegalArgumentException} if
* the condition is not met (evaluates to {@code false}).
*
* @param condition The condition to check
- *
+ *
* @throws IllegalArgumentException Thrown, if the condition is violated.
*/
public static void checkArgument(boolean condition) {
@@ -131,7 +131,7 @@ public final class Preconditions {
*
* @param condition The condition to check
* @param errorMessage The message for the {@code IllegalArgumentException} that is thrown if the check fails.
- *
+ *
* @throws IllegalArgumentException Thrown, if the condition is violated.
*/
public static void checkArgument(boolean condition, @Nullable Object errorMessage) {
@@ -150,13 +150,13 @@ public final class Preconditions {
* {@code %s} placeholders with the error message arguments.
* @param errorMessageArgs The arguments for the error message, to be inserted into the
* message template for the {@code %s} placeholders.
- *
+ *
* @throws IllegalArgumentException Thrown, if the condition is violated.
*/
public static void checkArgument(boolean condition,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
-
+
if (!condition) {
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
}
@@ -165,7 +165,7 @@ public final class Preconditions {
// ------------------------------------------------------------------------
// Boolean Condition Checking (State)
// ------------------------------------------------------------------------
-
+
/**
* Checks the given boolean condition, and throws an {@code IllegalStateException} if
* the condition is not met (evaluates to {@code false}).
@@ -220,10 +220,10 @@ public final class Preconditions {
/**
* Ensures that the given index is valid for an array, list or string of the given size.
- *
+ *
* @param index index to check
* @param size size of the array, list or string
- *
+ *
* @throws IllegalArgumentException Thrown, if size is negative.
* @throws IndexOutOfBoundsException Thrown, if the index negative or greater than or equal to size
*/
@@ -239,7 +239,7 @@ public final class Preconditions {
*
* @param index index to check
* @param size size of the array, list or string
- * @param errorMessage The message for the {@code IndexOutOfBoundsException} that is thrown if the check fails.
+ * @param errorMessage The message for the {@code IndexOutOfBoundsException} that is thrown if the check fails.
*
* @throws IllegalArgumentException Thrown, if size is negative.
* @throws IndexOutOfBoundsException Thrown, if the index negative or greater than or equal to size
@@ -258,13 +258,13 @@ public final class Preconditions {
/**
* A simplified formatting method. Similar to {@link String#format(String, Object...)}, but
* with lower overhead (only String parameters, no locale, no format validation).
- *
+ *
* <p>This method is taken quasi verbatim from the Guava Preconditions class.
*/
private static String format(@Nullable String template, @Nullable Object... args) {
final int numArgs = args == null ? 0 : args.length;
template = String.valueOf(template); // null -> "null"
-
+
// start substituting the arguments into the '%s' placeholders
StringBuilder builder = new StringBuilder(template.length() + 16 * numArgs);
int templateStart = 0;
@@ -296,6 +296,6 @@ public final class Preconditions {
// ------------------------------------------------------------------------
- /** Private constructor to prevent instantiation */
+ /** Private constructor to prevent instantiation. */
private Preconditions() {}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java b/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java
index 8650dcd..37d8a42 100644
--- a/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java
@@ -34,7 +34,6 @@ public class PropertiesUtil {
* @param key key in Properties
* @param defaultValue default value if value is not set
* @return default or value of key
- * @throws IllegalArgumentException
*/
public static int getInt(Properties config, String key, int defaultValue) {
String val = config.getProperty(key);
@@ -58,7 +57,6 @@ public class PropertiesUtil {
* @param key key in Properties
* @param defaultValue default value if value is not set
* @return default or value of key
- * @throws IllegalArgumentException
*/
public static long getLong(Properties config, String key, long defaultValue) {
String val = config.getProperty(key);
@@ -82,12 +80,11 @@ public class PropertiesUtil {
* @param key key in Properties
* @param defaultValue default value if value is not set
* @return default or value of key
- * @throws IllegalArgumentException
*/
public static long getLong(Properties config, String key, long defaultValue, Logger logger) {
try {
return getLong(config, key, defaultValue);
- } catch(IllegalArgumentException iae) {
+ } catch (IllegalArgumentException iae) {
logger.warn(iae.getMessage());
return defaultValue;
}
@@ -112,7 +109,7 @@ public class PropertiesUtil {
}
// ------------------------------------------------------------------------
-
- /** Private default constructor to prevent instantiation */
+
+ /** Private default constructor to prevent instantiation. */
private PropertiesUtil() {}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java b/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java
index 2883570..c212ca8 100644
--- a/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.apache.flink.util;
import org.apache.flink.annotation.Internal;
@@ -27,8 +26,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
+/**
+ * Utility for reflection operations on classes and generic type parametrization.
+ */
@Internal
+@SuppressWarnings("unused")
public final class ReflectionUtil {
+
public static <T> T newInstance(Class<T> clazz) {
try {
return clazz.newInstance();
@@ -41,16 +45,17 @@ public final class ReflectionUtil {
public static <T> Class<T> getTemplateType(Class<?> clazz, int num) {
return (Class<T>) getSuperTemplateTypes(clazz)[num];
}
-
+
@SuppressWarnings("unchecked")
public static <T> Class<T> getTemplateType(Class<?> clazz, Class<?> classWithParameter, int num) {
return (Class<T>) getSuperTemplateTypes(clazz)[num];
}
-
+
public static <T> Class<T> getTemplateType1(Class<?> clazz) {
return getTemplateType(clazz, 0);
}
+ @SuppressWarnings("unchecked")
public static <T> Class<T> getTemplateType1(Type type) {
if (type instanceof ParameterizedType) {
return (Class<T>) getTemplateTypes((ParameterizedType) type)[0];
@@ -102,13 +107,13 @@ public final class ReflectionUtil {
clazz = clazz.getSuperclass();
}
}
-
+
public static Class<?>[] getSuperTemplateTypes(Class<?> clazz, Class<?> searchedSuperClass) {
if (clazz == null || searchedSuperClass == null) {
throw new NullPointerException();
}
-
- Class<?> superClass = null;
+
+ Class<?> superClass;
do {
superClass = clazz.getSuperclass();
if (superClass == searchedSuperClass) {
@@ -116,11 +121,11 @@ public final class ReflectionUtil {
}
}
while ((clazz = superClass) != null);
-
+
if (clazz == null) {
throw new IllegalArgumentException("The searched for superclass is not a superclass of the given class.");
}
-
+
final Type type = clazz.getGenericSuperclass();
if (type instanceof ParameterizedType) {
return getTemplateTypes((ParameterizedType) type);
@@ -185,7 +190,7 @@ public final class ReflectionUtil {
templateTypeInfos[i] = getFullTemplateType(parameterizedType.getActualTypeArguments()[i]);
}
- return new FullTypeInfo((Class<?>)parameterizedType.getRawType(), templateTypeInfos);
+ return new FullTypeInfo((Class<?>) parameterizedType.getRawType(), templateTypeInfos);
} else {
return new FullTypeInfo((Class<?>) type, null);
}
@@ -197,10 +202,10 @@ public final class ReflectionUtil {
* describing the type.
*/
public static class FullTypeInfo {
+
private final Class<?> clazz;
private final FullTypeInfo[] templateTypeInfos;
-
public FullTypeInfo(Class<?> clazz, FullTypeInfo[] templateTypeInfos) {
this.clazz = Preconditions.checkNotNull(clazz);
this.templateTypeInfos = templateTypeInfos;
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/SerializableObject.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/SerializableObject.java b/flink-core/src/main/java/org/apache/flink/util/SerializableObject.java
index ec01731..f6e4a97 100644
--- a/flink-core/src/main/java/org/apache/flink/util/SerializableObject.java
+++ b/flink-core/src/main/java/org/apache/flink/util/SerializableObject.java
@@ -23,6 +23,6 @@ package org.apache.flink.util;
* in serializable classes.
*/
public class SerializableObject implements java.io.Serializable {
-
+
private static final long serialVersionUID = -7322636177391854669L;
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/SerializedThrowable.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/SerializedThrowable.java b/flink-core/src/main/java/org/apache/flink/util/SerializedThrowable.java
index 3cab55b..de6358c 100644
--- a/flink-core/src/main/java/org/apache/flink/util/SerializedThrowable.java
+++ b/flink-core/src/main/java/org/apache/flink/util/SerializedThrowable.java
@@ -31,22 +31,22 @@ import static java.util.Objects.requireNonNull;
* Utility class for dealing with user-defined Throwable types that are serialized (for
* example during RPC/Actor communication), but cannot be resolved with the default
* class loader.
- *
+ *
* <p>This exception mimics the original exception with respect to message and stack trace,
* and contains the original exception in serialized form. The original exception
* can be re-obtained by supplying the appropriate class loader.
*/
public class SerializedThrowable extends Exception implements Serializable {
-
+
private static final long serialVersionUID = 7284183123441947635L;
-
- /** The original exception in serialized form */
+
+ /** The original exception in serialized form. */
private final byte[] serializedException;
-
- /** Name of the original error class */
+
+ /** Name of the original error class. */
private final String originalErrorClassName;
-
- /** The original stack trace, to be printed */
+
+ /** The original stack trace, to be printed. */
private final String fullStringifiedStackTrace;
/** The original exception, not transported via serialization,
@@ -57,11 +57,11 @@ public class SerializedThrowable extends Exception implements Serializable {
/**
* Create a new SerializedThrowable.
- *
+ *
* @param exception The exception to serialize.
*/
public SerializedThrowable(Throwable exception) {
- this(exception, new HashSet<Throwable>());
+ this(exception, new HashSet<>());
}
/**
@@ -89,7 +89,7 @@ public class SerializedThrowable extends Exception implements Serializable {
serialized = null;
}
this.serializedException = serialized;
- this.cachedException = new WeakReference<Throwable>(exception);
+ this.cachedException = new WeakReference<>(exception);
// record the original exception's properties (name, stack prints)
this.originalErrorClassName = exception.getClass().getName();
@@ -103,7 +103,7 @@ public class SerializedThrowable extends Exception implements Serializable {
initCause(null);
}
else {
- // exception causes may by cyclic, so we truncate the cycle when we find it
+ // exception causes may by cyclic, so we truncate the cycle when we find it
if (alreadySeen.add(exception)) {
// we are not in a cycle, yet
initCause(new SerializedThrowable(exception.getCause(), alreadySeen));
@@ -134,7 +134,7 @@ public class SerializedThrowable extends Exception implements Serializable {
if (cached == null) {
try {
cached = InstantiationUtil.deserializeObject(serializedException, classloader);
- cachedException = new WeakReference<Throwable>(cached);
+ cachedException = new WeakReference<>(cached);
}
catch (Throwable t) {
// something went wrong
@@ -166,13 +166,13 @@ public class SerializedThrowable extends Exception implements Serializable {
s.print(fullStringifiedStackTrace);
s.flush();
}
-
+
@Override
public void printStackTrace(PrintWriter s) {
s.print(fullStringifiedStackTrace);
s.flush();
}
-
+
@Override
public String toString() {
String message = getLocalizedMessage();
@@ -185,7 +185,7 @@ public class SerializedThrowable extends Exception implements Serializable {
public static Throwable get(Throwable serThrowable, ClassLoader loader) {
if (serThrowable instanceof SerializedThrowable) {
- return ((SerializedThrowable)serThrowable).deserializeError(loader);
+ return ((SerializedThrowable) serThrowable).deserializeError(loader);
} else {
return serThrowable;
}
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/SerializedValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/SerializedValue.java b/flink-core/src/main/java/org/apache/flink/util/SerializedValue.java
index d91c14e..32f9642 100644
--- a/flink-core/src/main/java/org/apache/flink/util/SerializedValue.java
+++ b/flink-core/src/main/java/org/apache/flink/util/SerializedValue.java
@@ -28,7 +28,7 @@ import java.util.Arrays;
* in the system class loader. When those objects are deserialized without access to their
* special class loader, the deserialization fails with a {@code ClassNotFoundException}.
*
- * To work around that issue, the SerializedValue serialized data immediately into a byte array.
+ * <p>To work around that issue, the SerializedValue serialized data immediately into a byte array.
* When send through RPC or another service that uses serialization, only the byte array is
* transferred. The object is deserialized later (upon access) and requires the accessor to
* provide the corresponding class loader.
@@ -40,7 +40,7 @@ public class SerializedValue<T> implements java.io.Serializable {
private static final long serialVersionUID = -3564011643393683761L;
- /** The serialized data */
+ /** The serialized data. */
private final byte[] serializedData;
private SerializedValue(byte[] serializedData) {
@@ -68,7 +68,7 @@ public class SerializedValue<T> implements java.io.Serializable {
}
public static <T> SerializedValue<T> fromBytes(byte[] serializedData) {
- return new SerializedValue<T>(serializedData);
+ return new SerializedValue<>(serializedData);
}
// --------------------------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/SplittableIterator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/SplittableIterator.java b/flink-core/src/main/java/org/apache/flink/util/SplittableIterator.java
index bb7f9af..993c521 100644
--- a/flink-core/src/main/java/org/apache/flink/util/SplittableIterator.java
+++ b/flink-core/src/main/java/org/apache/flink/util/SplittableIterator.java
@@ -18,14 +18,15 @@
package org.apache.flink.util;
+import org.apache.flink.annotation.Public;
+
import java.io.Serializable;
import java.util.Iterator;
-import org.apache.flink.annotation.Public;
/**
* Abstract base class for iterators that can split themselves into multiple disjoint
* iterators. The union of these iterators returns the original iterator values.
- *
+ *
* @param <T> The type of elements returned by the iterator.
*/
@Public
@@ -36,7 +37,7 @@ public abstract class SplittableIterator<T> implements Iterator<T>, Serializable
/**
* Splits this iterator into a number disjoint iterators.
* The union of these iterators returns the original iterator values.
- *
+ *
* @param numPartitions The number of iterators to split into.
* @return An array with the split iterators.
*/
@@ -45,7 +46,7 @@ public abstract class SplittableIterator<T> implements Iterator<T>, Serializable
/**
* Splits this iterator into <i>n</i> partitions and returns the <i>i-th</i> partition
* out of those.
- *
+ *
* @param num The partition to return (<i>i</i>).
* @param numPartitions The number of partitions to split into (<i>n</i>).
* @return The iterator for the partition.
@@ -60,7 +61,7 @@ public abstract class SplittableIterator<T> implements Iterator<T>, Serializable
/**
* The maximum number of splits into which this iterator can be split up.
- *
+ *
* @return The maximum number of splits into which this iterator can be split up.
*/
public abstract int getMaximumNumberOfSplits();
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/StateMigrationException.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/StateMigrationException.java b/flink-core/src/main/java/org/apache/flink/util/StateMigrationException.java
index 1667ff5..00e0e73 100644
--- a/flink-core/src/main/java/org/apache/flink/util/StateMigrationException.java
+++ b/flink-core/src/main/java/org/apache/flink/util/StateMigrationException.java
@@ -19,7 +19,7 @@
package org.apache.flink.util;
/**
- * Base class for state migration related exceptions
+ * Base class for state migration related exceptions.
*/
public class StateMigrationException extends FlinkException {
private static final long serialVersionUID = 8268516412747670839L;
http://git-wip-us.apache.org/repos/asf/flink/blob/212ee3d4/flink-core/src/main/java/org/apache/flink/util/StringBasedID.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/util/StringBasedID.java b/flink-core/src/main/java/org/apache/flink/util/StringBasedID.java
index fe03fa9..7ec8df5 100644
--- a/flink-core/src/main/java/org/apache/flink/util/StringBasedID.java
+++ b/flink-core/src/main/java/org/apache/flink/util/StringBasedID.java
@@ -29,7 +29,7 @@ public class StringBasedID implements Serializable {
private static final long serialVersionUID = 1L;
/**
- * Uses a String as internal representation
+ * Uses a String as internal representation.
*/
private final String keyString;