JavaBeans
+ * See the JavaBeans
* specification for more details as to what constitutes a property.
*/
@SuppressWarnings({
@@ -277,7 +277,7 @@ private Builder(String[] args, boolean validation, boolean strictParsing, boolea
* PipelineOptionsFactory#printHelp(PrintStream, Class)}.
*/
public Builder fromArgs(String... args) {
- checkNotNull(args, "Arguments should not be null.");
+ checkArgumentNotNull(args, "Arguments should not be null.");
return new Builder(args, validation, strictParsing, true);
}
@@ -338,7 +338,8 @@ public T as(Class klass) {
appNameOptions.setAppName(defaultAppName);
}
- // Ensure the options id has been populated either by the user using the command line
+ // Ensure the options id has been populated either by the user using the command
+ // line
// or by the default value factory.
t.getOptionsId();
@@ -433,7 +434,8 @@ private static String findCallersClassName() {
break;
}
}
- // Then find the first instance after that is not the PipelineOptionsFactory/Builder class.
+ // Then find the first instance after that is not the
+ // PipelineOptionsFactory/Builder class.
while (elements.hasNext()) {
StackTraceElement next = elements.next();
if (!PIPELINE_OPTIONS_FACTORY_CLASSES.contains(next.getClassName())) {
@@ -587,7 +589,7 @@ public static Set> getRegisteredOptions() {
* window.
*/
public static void printHelp(PrintStream out) {
- checkNotNull(out);
+ checkArgumentNotNull(out);
out.println("The set of registered options are:");
Set> sortedOptions =
new TreeSet<>(ClassNameComparator.INSTANCE);
@@ -622,8 +624,8 @@ public static void printHelp(PrintStream out) {
* This method will attempt to format its output to be compatible with a terminal window.
*/
public static void printHelp(PrintStream out, Class extends PipelineOptions> iface) {
- checkNotNull(out);
- checkNotNull(iface);
+ checkArgumentNotNull(out);
+ checkArgumentNotNull(iface);
CACHE.get().validateWellFormed(iface);
Set properties = PipelineOptionsReflector.getOptionSpecs(iface, true);
@@ -697,7 +699,7 @@ public static void printHelp(PrintStream out, Class extends PipelineOptions> i
*/
public static List describe(
Set> ifaces) {
- checkNotNull(ifaces);
+ checkArgumentNotNull(ifaces);
List result = new ArrayList<>();
Set seenMethods = Sets.newHashSet();
@@ -869,7 +871,8 @@ private static List getPropertyDescriptors(Set metho
List mismatches = new ArrayList<>();
Set usedDescriptors = Sets.newHashSet();
/*
- * Add all the getter/setter pairs to the list of descriptors removing the getter once
+ * Add all the getter/setter pairs to the list of descriptors removing the
+ * getter once
* it has been paired up.
*/
for (Method method : methods) {
@@ -995,7 +998,8 @@ private static List validateClass(
+ "PipelineOptions proxy class to implement all of the interfaces.",
iface.getName());
- // Verify that there are no methods with the same name with two different return types.
+ // Verify that there are no methods with the same name with two different return
+ // types.
validateReturnType(iface);
SortedSet allInterfaceMethods =
@@ -1098,7 +1102,8 @@ private static void validateMethodAnnotations(
validateGettersHaveConsistentAnnotation(
methodNameToAllMethodMap, descriptors, AnnotationPredicates.JSON_SERIALIZE);
- // Verify that if a method has either @JsonSerialize or @JsonDeserialize then it has both.
+ // Verify that if a method has either @JsonSerialize or @JsonDeserialize then it
+ // has both.
validateMethodsHaveBothJsonSerializeAndDeserialize(descriptors);
// Verify that no setter has @JsonIgnore.
@@ -1280,7 +1285,8 @@ private static void validateMethodsAreEitherBeanMethodOrKnownMethod(
knownMethodsNames.add(method.getName());
}
- // Verify that no additional methods are on an interface that aren't a bean property.
+ // Verify that no additional methods are on an interface that aren't a bean
+ // property.
// Because methods can have multiple declarations, we do a name-based comparison
// here to prevent false positives.
SortedSet unknownMethods = new TreeSet<>(MethodComparator.INSTANCE);
@@ -1823,7 +1829,8 @@ private static Object tryParseObject(String value, Method method) throws IOExcep
try {
tree = MAPPER.readTree("\"" + value + "\"");
} catch (JsonParseException inner) {
- // rethrow the original exception rather the one thrown from the fallback attempt
+ // rethrow the original exception rather the one thrown from the fallback
+ // attempt
throw e;
}
} else {
@@ -1891,7 +1898,8 @@ private static Map parseObjects(
}
}
Method method = propertyNamesToGetters.get(entry.getKey());
- // Only allow empty argument values for String, String Array, and Collection.
+ // Only allow empty argument values for String, String Array, and
+ // Collection.
Class> returnType = method.getReturnType();
JavaType type = MAPPER.getTypeFactory().constructType(method.getGenericReturnType());
@@ -2089,7 +2097,7 @@ private void initializeRegistry(final ClassLoader loader) {
}
private synchronized void register(Class extends PipelineOptions> iface) {
- checkNotNull(iface);
+ checkArgumentNotNull(iface);
checkArgument(iface.isInterface(), "Only interface types are supported.");
if (registeredOptions.contains(iface)) {
@@ -2144,7 +2152,8 @@ synchronized Registration validateWellFormed(
Class iface, Set> validatedPipelineOptionsInterfaces) {
checkArgument(iface.isInterface(), "Only interface types are supported.");
- // Validate that every inherited interface must extend PipelineOptions except for
+ // Validate that every inherited interface must extend PipelineOptions except
+ // for
// PipelineOptions itself.
validateInheritedInterfacesExtendPipelineOptions(iface);
@@ -2152,7 +2161,8 @@ synchronized Registration validateWellFormed(
Set> combinedPipelineOptionsInterfaces =
Stream.concat(validatedPipelineOptionsInterfaces.stream(), Stream.of(iface))
.collect(Collectors.toSet());
- // Validate that the view of all currently passed in options classes is well formed.
+ // Validate that the view of all currently passed in options classes is well
+ // formed.
if (!combinedCache.containsKey(combinedPipelineOptionsInterfaces)) {
final Class>[] interfaces = combinedPipelineOptionsInterfaces.toArray(EMPTY_CLASS_ARRAY);
@SuppressWarnings("unchecked")
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsValidator.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsValidator.java
index 7635c35da1cf..6892fae39ffa 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsValidator.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsValidator.java
@@ -17,8 +17,8 @@
*/
package org.apache.beam.sdk.options;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
-import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -67,8 +67,8 @@ public static T validateCli(Class klass, Pipeline
private static T validate(
Class klass, PipelineOptions options, boolean isCli) {
- checkNotNull(klass);
- checkNotNull(options);
+ checkArgumentNotNull(klass);
+ checkArgumentNotNull(options);
checkArgument(Proxy.isProxyClass(options.getClass()));
checkArgument(Proxy.getInvocationHandler(options) instanceof ProxyInvocationHandler);
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
index 7a9cc8568ee0..a20af2d1a590 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
@@ -17,8 +17,8 @@
*/
package org.apache.beam.sdk.options;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
-import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -82,9 +82,9 @@
* introspection of the proxy class to store and retrieve values based off of the property name.
*
* Unset properties use the {@code @Default} metadata on the getter to return values. If there is
- * no {@code @Default} annotation on the getter, then a default as
- * per the Java Language Specification for the expected return type is returned.
+ * no {@code @Default} annotation on the getter, then a default as per the
+ * Java Language Specification for the expected return type is returned.
*
*
In addition to the getter/setter pairs, this proxy invocation handler supports {@link
* Object#equals(Object)}, {@link Object#hashCode()}, {@link Object#toString()} and {@link
@@ -122,7 +122,8 @@ private ComputedProperties(
ComputedProperties updated(
Class iface, T instance, List propertyDescriptors) {
- // these all use mutable maps and then copyOf, rather than a builder because builders enforce
+ // these all use mutable maps and then copyOf, rather than a builder because
+ // builders enforce
// all keys are unique, and its possible they are not here.
Map allNewGetters = Maps.newHashMap(gettersToPropertyNames);
Map allNewSetters = Maps.newHashMap(settersToPropertyNames);
@@ -147,7 +148,8 @@ ComputedProperties updated(
@SuppressFBWarnings("SE_BAD_FIELD")
private volatile ComputedProperties computedProperties;
- // ProxyInvocationHandler implements Serializable only for the sake of throwing an informative
+ // ProxyInvocationHandler implements Serializable only for the sake of throwing
+ // an informative
// exception in writeObject()
/**
* Enumerating {@code options} must always be done on a copy made before accessing or deriving
@@ -217,7 +219,8 @@ public Object invoke(Object proxy, Method method, Object[] args) {
ComputedProperties properties = computedProperties;
if (properties.gettersToPropertyNames.containsKey(methodName)) {
String propertyName = properties.gettersToPropertyNames.get(methodName);
- // we can't use computeIfAbsent here because evaluating the default may cause more properties
+ // we can't use computeIfAbsent here because evaluating the default may cause
+ // more properties
// to be evaluated, and computeIfAbsent is not re-entrant.
if (!options.containsKey(propertyName)) {
// Lazy bind the default to the method.
@@ -286,7 +289,7 @@ static BoundValue fromDefault(@Nullable Object value) {
* @return An object that implements the interface {@code }.
*/
T as(Class iface) {
- checkNotNull(iface);
+ checkArgumentNotNull(iface);
checkArgument(iface.isInterface(), "Not an interface: %s", iface);
T existingOption = computedProperties.interfaceToProxyCache.getInstance(iface);
@@ -376,8 +379,10 @@ class PipelineOptionsDisplayData implements HasDisplayData {
*/
@Override
public void populateDisplayData(DisplayData.Builder builder) {
- // We must first make a copy of the current options because a concurrent modification
- // may add a new option after we have derived optionSpecs but before we have enumerated
+ // We must first make a copy of the current options because a concurrent
+ // modification
+ // may add a new option after we have derived optionSpecs but before we have
+ // enumerated
// all the pipeline options.
Map copiedOptions = new HashMap<>(options);
Set optionSpecs =
@@ -396,8 +401,10 @@ public void populateDisplayData(DisplayData.Builder builder) {
for (PipelineOptionSpec optionSpec : specs) {
if (!optionSpec.shouldSerialize()) {
- // Options that are excluded for serialization (i.e. those with @JsonIgnore) are also
- // excluded from display data. These options are generally not useful for display.
+ // Options that are excluded for serialization (i.e. those with @JsonIgnore) are
+ // also
+ // excluded from display data. These options are generally not useful for
+ // display.
continue;
}
@@ -481,7 +488,8 @@ private static String displayDataString(@Nullable Object value) {
return Arrays.deepToString((Object[]) value);
}
- // At this point, we have some type of primitive array. Arrays.deepToString(..) requires an
+ // At this point, we have some type of primitive array. Arrays.deepToString(..)
+ // requires an
// Object array, but will unwrap nested primitive arrays.
String wrapped = Arrays.deepToString(new Object[] {value});
return wrapped.substring(1, wrapped.length() - 1);
@@ -514,12 +522,17 @@ private Multimap buildOptionNameToSpecMap(
// Filter out overridden options
for (Map.Entry> entry : optionsMap.asMap().entrySet()) {
- /* Compare all interfaces for an option pairwise (iface1, iface2) to look for type
- hierarchies. If one is the base-class of the other, remove it from the output and continue
- iterating.
-
- This is an N^2 operation per-option, but the number of interfaces defining an option
- should always be small (usually 1). */
+ /*
+ * Compare all interfaces for an option pairwise (iface1, iface2) to look for
+ * type
+ * hierarchies. If one is the base-class of the other, remove it from the output
+ * and continue
+ * iterating.
+ *
+ * This is an N^2 operation per-option, but the number of interfaces defining an
+ * option
+ * should always be small (usually 1).
+ */
List specs = Lists.newArrayList(entry.getValue());
if (specs.size() < 2) {
// Only one known implementing interface, no need to check for inheritance
@@ -600,9 +613,9 @@ private static Object getValueFromJson(JsonNode node, Method method) {
/**
* Returns a default value for the method based upon {@code @Default} metadata on the getter to
- * return values. If there is no {@code @Default} annotation on the getter, then a default as
- * per the Java Language Specification for the expected return type is returned.
+ * return values. If there is no {@code @Default} annotation on the getter, then a default as per
+ * the Java Language Specification for the expected return type is returned.
*
* @param proxy The proxy object for which we are attempting to get the default.
* @param method The getter method that was invoked.
@@ -651,7 +664,8 @@ private Object getDefault(PipelineOptions proxy, Method method) {
}
/*
- * We need to make sure that we return something appropriate for the return type. Thus we return
+ * We need to make sure that we return something appropriate for the return
+ * type. Thus we return
* a default value as defined by the JLS.
*/
return Defaults.defaultValue(method.getReturnType());
@@ -750,7 +764,8 @@ public void serialize(PipelineOptions value, JsonGenerator jgen, SerializerProvi
throws IOException {
ProxyInvocationHandler handler = (ProxyInvocationHandler) Proxy.getInvocationHandler(value);
PipelineOptionsFactory.Cache cache = PipelineOptionsFactory.CACHE.get();
- // We first copy and then filter out any properties that have been modified since
+ // We first copy and then filter out any properties that have been modified
+ // since
// the last serialization of this PipelineOptions and then verify that
// they are all serializable.
Map filteredOptions = Maps.newHashMap(handler.options);
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/SdkHarnessOptions.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/SdkHarnessOptions.java
index 5833bcc21a42..831dd69ec95f 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/SdkHarnessOptions.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/SdkHarnessOptions.java
@@ -17,7 +17,8 @@
*/
package org.apache.beam.sdk.options;
-import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
+import static org.apache.beam.sdk.util.Preconditions.checkStateNotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -218,7 +219,7 @@ class DefaultMaxCacheMemoryUsageMbFactory implements DefaultValueFactory<@NonNeg
public @NonNegative Integer create(PipelineOptions options) {
SdkHarnessOptions sdkHarnessOptions = options.as(SdkHarnessOptions.class);
return (Integer)
- checkNotNull(
+ checkStateNotNull(
InstanceBuilder.ofType(MaxCacheMemoryUsageMb.class)
.fromClass(sdkHarnessOptions.getMaxCacheMemoryUsageMbClass())
.build()
@@ -289,7 +290,7 @@ class SdkHarnessLogLevelOverrides extends HashMap {
* the {@link Class#getName() class name}.
*/
public SdkHarnessLogLevelOverrides addOverrideForClass(Class> klass, LogLevel logLevel) {
- checkNotNull(klass, "Expected class to be not null.");
+ checkArgumentNotNull(klass, "Expected class to be not null.");
addOverrideForName(klass.getName(), logLevel);
return this;
}
@@ -301,7 +302,7 @@ public SdkHarnessLogLevelOverrides addOverrideForClass(Class> klass, LogLevel
* the {@link Package#getName() package name}.
*/
public SdkHarnessLogLevelOverrides addOverrideForPackage(Package pkg, LogLevel logLevel) {
- checkNotNull(pkg, "Expected package to be not null.");
+ checkArgumentNotNull(pkg, "Expected package to be not null.");
addOverrideForName(pkg.getName(), logLevel);
return this;
}
@@ -314,8 +315,8 @@ public SdkHarnessLogLevelOverrides addOverrideForPackage(Package pkg, LogLevel l
* in name.
*/
public SdkHarnessLogLevelOverrides addOverrideForName(String name, LogLevel logLevel) {
- checkNotNull(name, "Expected name to be not null.");
- checkNotNull(
+ checkArgumentNotNull(name, "Expected name to be not null.");
+ checkArgumentNotNull(
logLevel, "Expected logLevel to be one of %s.", Arrays.toString(LogLevel.values()));
put(name, logLevel);
return this;
@@ -329,7 +330,7 @@ public SdkHarnessLogLevelOverrides addOverrideForName(String name, LogLevel logL
*/
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static SdkHarnessLogLevelOverrides from(Map values) {
- checkNotNull(values, "Expected values to be not null.");
+ checkArgumentNotNull(values, "Expected values to be not null.");
SdkHarnessLogLevelOverrides overrides = new SdkHarnessLogLevelOverrides();
for (Map.Entry entry : values.entrySet()) {
String module = entry.getKey();
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java
index 54b31a252b99..9cfedd42c774 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java
@@ -17,7 +17,8 @@
*/
package org.apache.beam.sdk.options;
-import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
+import static org.apache.beam.sdk.util.Preconditions.checkStateNotNull;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
@@ -129,8 +130,8 @@ class NestedValueProvider implements ValueProvider, Serializable {
private transient volatile T cachedValue;
NestedValueProvider(ValueProvider value, SerializableFunction translator) {
- this.value = checkNotNull(value);
- this.translator = checkNotNull(translator);
+ this.value = checkArgumentNotNull(value);
+ this.translator = checkArgumentNotNull(translator);
}
/** Creates a {@link NestedValueProvider} that wraps the provided value. */
@@ -261,7 +262,7 @@ public T get() {
@SuppressWarnings("unchecked")
ValueProvider result = (ValueProvider) handler.invoke(methodOptions, method, null);
// Two cases: If we have deserialized a new value from JSON, it will
- // be wrapped in a StaticValueProvider, which we can provide here. If
+ // be wrapped in a StaticValueProvider, which we can provide here. If
// not, there was no JSON value, and we return the default, whether or
// not it is null.
if (result instanceof StaticValueProvider) {
@@ -342,8 +343,8 @@ class Deserializer extends JsonDeserializer> implements Context
@Override
public JsonDeserializer> createContextual(DeserializationContext ctxt, BeanProperty property)
throws JsonMappingException {
- checkNotNull(ctxt, "Null DeserializationContext.");
- JavaType type = checkNotNull(ctxt.getContextualType(), "Invalid type: %s", getClass());
+ checkArgumentNotNull(ctxt, "Null DeserializationContext.");
+ JavaType type = checkStateNotNull(ctxt.getContextualType(), "Invalid type: %s", getClass());
JavaType[] params = type.findTypeParameters(ValueProvider.class);
if (params.length != 1) {
throw new RuntimeException("Unable to derive type for ValueProvider: " + type.toString());
@@ -357,7 +358,7 @@ public ValueProvider> deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonDeserializer dser =
ctxt.findRootValueDeserializer(
- checkNotNull(
+ checkStateNotNull(
innerType, "Invalid %s: innerType is null. Serialization error?", getClass()));
Object o = dser.deserialize(jp, ctxt);
return StaticValueProvider.of(o);
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProviders.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProviders.java
index e88dab7eb2a7..d1c9f9578817 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProviders.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProviders.java
@@ -17,7 +17,7 @@
*/
package org.apache.beam.sdk.options;
-import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.beam.sdk.util.Preconditions.checkStateNotNull;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
@@ -41,7 +41,7 @@ public static String updateSerializedOptions(
try {
root = PipelineOptionsFactory.MAPPER.readValue(serializedOptions, ObjectNode.class);
options = (ObjectNode) root.get("options");
- checkNotNull(options, "Unable to locate 'options' in %s", serializedOptions);
+ checkStateNotNull(options, "Unable to locate 'options' in %s", serializedOptions);
} catch (IOException e) {
throw new RuntimeException(String.format("Unable to parse %s", serializedOptions), e);
}
diff --git a/start-build-env.sh b/start-build-env.sh
index 0f23f32a269c..9c96ff786259 100755
--- a/start-build-env.sh
+++ b/start-build-env.sh
@@ -37,7 +37,7 @@ USER_ID=$(id -u "${USER_NAME}")
if [ "$(uname -s)" = "Darwin" ]; then
GROUP_ID=100
- if (dscl . -read /Groups/docker 2>/dev/null); then
+ if (dscl . -read /Groups/docker 2>/dev/null); then
DOCKER_GROUP_ID=$(dscl . -read /Groups/docker| awk '($1 == "PrimaryGroupID:") { print $2 }')
else
# if Docker post-install steps to manage as non-root user not performed - will use dummy gid
@@ -85,7 +85,7 @@ docker build -t "beam-build-${USER_ID}" - < "/etc/sudoers.d/beam-build-${USER_ID}"
ENV HOME "${DOCKER_HOME_DIR}"