Preconditions.checkState(value <= threshold, "value must be below " + threshold)LOG.debug("value is " + value)Preconditions.checkState(value <= threshold, "value must be below %s", threshold)LOG.debug("value is {}", value)equals()/hashCode() methods suggest to use the type as a key, but the signatures suggest it is safe to keep mutating the type.Do not use Java Serialization for anything !!!
Do not use Java Serialization for anything !!! !!!
Do not use Java Serialization for anything !!! !!! !!!
Internal to Flink, Java serialization is used to transport messages and programs through RPC. This is the only case where we use Java serialization. Because of that, some classes need to be serializable (if they are transported via RPC).
Serializable classes must define a Serial Version UID:
private static final long serialVersionUID = 1L;
The Serial Version UID for new classes should start at 1 and should generally be bumped on every incompatible change to the class according to the Java serialization compatibility definition (i.e: changing the type of a field, or moving the position of a class in the class hierarchy).
Avoid using Java’s Reflection API
contains() before get() → get() and check nullcontains() before put() → putIfAbsent() or computeIfAbsent()entrySet()Optional usage would lead to a performance degradation in critical code then fallback to @Nullable.Prefer non-capturing lambdas (lambdas that do not contain references to the outer scope). Capturing lambdas need to create a new object instance for every call. Non-capturing lambdas can use the same instance for each invocation.
don’t:
map.computeIfAbsent(key, x -> key.toLowerCase())
do:
map.computeIfAbsent(key, k -> k.toLowerCase());
Consider method references instead of inline lambdas
don’t:
map.computeIfAbsent(key, k-> Loader.load(k));
do:
map.computeIfAbsent(key, Loader::load);