This is an automated email from the ASF dual-hosted git repository.
kenn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 1052216416f Migrate remaining checkNotNull to
checkArgumentNotNull/checkStateNotNull in options package #18719 (#37654)
1052216416f is described below
commit 1052216416f4d77325f77e0af80fc0ee98979e14
Author: Chandra Kiran Bolla
<[email protected]>
AuthorDate: Fri Feb 20 14:30:53 2026 -0500
Migrate remaining checkNotNull to checkArgumentNotNull/checkStateNotNull in
options package #18719 (#37654)
* Start migrating argument null checks to checkArgumentNotNull (Issue
#18719)
* Migrate remaining checkNotNull to checkArgumentNotNull/checkStateNotNull
in options package
Replace Guava checkNotNull (throws NullPointerException) with Beam's
checkArgumentNotNull (throws IllegalArgumentException) for argument
validation and checkStateNotNull (throws IllegalStateException) for
internal state validation.
Files modified:
- SdkHarnessOptions.java: checkStateNotNull for return value check
- PipelineOptionsFactory.java: checkArgumentNotNull for argument check
- ValueProvider.java: checkArgumentNotNull + checkStateNotNull
- ValueProviders.java: checkStateNotNull for parsed result check
- PipelineOptionsValidator.java: checkArgumentNotNull for argument checks
- ProxyInvocationHandler.java: checkArgumentNotNull for argument check
- MetricNameFilter.java: cleanup commented-out import
Fixes #18719
---
.../apache/beam/sdk/metrics/MetricNameFilter.java | 8 +--
.../beam/sdk/options/PipelineOptionsFactory.java | 48 ++++++++++-------
.../beam/sdk/options/PipelineOptionsValidator.java | 6 +--
.../beam/sdk/options/ProxyInvocationHandler.java | 63 +++++++++++++---------
.../apache/beam/sdk/options/SdkHarnessOptions.java | 15 +++---
.../org/apache/beam/sdk/options/ValueProvider.java | 15 +++---
.../apache/beam/sdk/options/ValueProviders.java | 4 +-
start-build-env.sh | 4 +-
8 files changed, 95 insertions(+), 68 deletions(-)
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricNameFilter.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricNameFilter.java
index 704df17fc70..9e205435d13 100644
---
a/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricNameFilter.java
+++
b/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricNameFilter.java
@@ -17,7 +17,7 @@
*/
package org.apache.beam.sdk.metrics;
-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 com.google.auto.value.AutoValue;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -41,13 +41,13 @@ public abstract class MetricNameFilter {
}
public static MetricNameFilter named(String namespace, String name) {
- checkNotNull(name, "Must specify a name");
+ checkArgumentNotNull(name, "Must specify a name");
return new AutoValue_MetricNameFilter(namespace, name);
}
public static MetricNameFilter named(Class<?> namespace, String name) {
- checkNotNull(namespace, "Must specify a inNamespace");
- checkNotNull(name, "Must specify a name");
+ checkArgumentNotNull(namespace, "Must specify a namespace");
+ checkArgumentNotNull(name, "Must specify a name");
return new AutoValue_MetricNameFilter(namespace.getName(), name);
}
}
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
index 9dbfa397a03..ac76a57b6b0 100644
---
a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
+++
b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
@@ -18,8 +18,8 @@
package org.apache.beam.sdk.options;
import static java.util.Locale.ROOT;
+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.JsonParseException;
@@ -133,8 +133,8 @@ import org.slf4j.LoggerFactory;
* registered with this factory.
* </ul>
*
- * <p>See the <a
- *
href="http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html">JavaBeans
+ * <p>See the <a href=
+ *
"http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html">JavaBeans
* specification</a> for more details as to what constitutes a property.
*/
@SuppressWarnings({
@@ -277,7 +277,7 @@ public class PipelineOptionsFactory {
* 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 class PipelineOptionsFactory {
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 @@ public class PipelineOptionsFactory {
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 class PipelineOptionsFactory {
* window.
*/
public static void printHelp(PrintStream out) {
- checkNotNull(out);
+ checkArgumentNotNull(out);
out.println("The set of registered options are:");
Set<Class<? extends PipelineOptions>> sortedOptions =
new TreeSet<>(ClassNameComparator.INSTANCE);
@@ -622,8 +624,8 @@ public class PipelineOptionsFactory {
* 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<PipelineOptionSpec> properties =
PipelineOptionsReflector.getOptionSpecs(iface, true);
@@ -697,7 +699,7 @@ public class PipelineOptionsFactory {
*/
public static List<PipelineOptionDescriptor> describe(
Set<Class<? extends PipelineOptions>> ifaces) {
- checkNotNull(ifaces);
+ checkArgumentNotNull(ifaces);
List<PipelineOptionDescriptor> result = new ArrayList<>();
Set<Method> seenMethods = Sets.newHashSet();
@@ -869,7 +871,8 @@ public class PipelineOptionsFactory {
List<TypeMismatch> mismatches = new ArrayList<>();
Set<String> 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 @@ public class PipelineOptionsFactory {
+ "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<Method> allInterfaceMethods =
@@ -1098,7 +1102,8 @@ public class PipelineOptionsFactory {
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 @@ public class PipelineOptionsFactory {
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<Method> unknownMethods = new
TreeSet<>(MethodComparator.INSTANCE);
@@ -1823,7 +1829,8 @@ public class PipelineOptionsFactory {
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 @@ public class PipelineOptionsFactory {
}
}
Method method = propertyNamesToGetters.get(entry.getKey());
- // Only allow empty argument values for String, String Array, and
Collection<String>.
+ // Only allow empty argument values for String, String Array, and
+ // Collection<String>.
Class<?> returnType = method.getReturnType();
JavaType type =
MAPPER.getTypeFactory().constructType(method.getGenericReturnType());
@@ -2089,7 +2097,7 @@ public class PipelineOptionsFactory {
}
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 @@ public class PipelineOptionsFactory {
Class<T> iface, Set<Class<? extends PipelineOptions>>
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 @@ public class PipelineOptionsFactory {
Set<Class<? extends PipelineOptions>> 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 7635c35da1c..6892fae39ff 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 class PipelineOptionsValidator {
private static <T extends PipelineOptions> T validate(
Class<T> 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 7a9cc8568ee..a20af2d1a59 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 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* introspection of the proxy class to store and retrieve values based off of
the property name.
*
* <p>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 <a
- *
href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a>
as
- * per the Java Language Specification for the expected return type is
returned.
+ * no {@code @Default} annotation on the getter, then a <a href=
+ *
"https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a>
as per the
+ * Java Language Specification for the expected return type is returned.
*
* <p>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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
<T extends PipelineOptions> ComputedProperties updated(
Class<T> iface, T instance, List<PropertyDescriptor>
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<String, String> allNewGetters =
Maps.newHashMap(gettersToPropertyNames);
Map<String, String> allNewSetters =
Maps.newHashMap(settersToPropertyNames);
@@ -147,7 +148,8 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
@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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
* @return An object that implements the interface {@code <T>}.
*/
<T extends PipelineOptions> T as(Class<T> iface) {
- checkNotNull(iface);
+ checkArgumentNotNull(iface);
checkArgument(iface.isInterface(), "Not an interface: %s", iface);
T existingOption =
computedProperties.interfaceToProxyCache.getInstance(iface);
@@ -376,8 +379,10 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
*/
@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<String, BoundValue> copiedOptions = new HashMap<>(options);
Set<PipelineOptionSpec> optionSpecs =
@@ -396,8 +401,10 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
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 @@ class ProxyInvocationHandler implements
InvocationHandler, Serializable {
// Filter out overridden options
for (Map.Entry<String, Collection<PipelineOptionSpec>> 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<PipelineOptionSpec> specs = Lists.newArrayList(entry.getValue());
if (specs.size() < 2) {
// Only one known implementing interface, no need to check for
inheritance
@@ -600,9 +613,9 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
/**
* 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 <a
- *
href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a>
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 <a href=
+ *
"https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a>
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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
}
/*
- * 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 @@ class ProxyInvocationHandler implements InvocationHandler,
Serializable {
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<String, BoundValue> 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 5833bcc21a4..831dd69ec95 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 @@ public interface SdkHarnessOptions extends PipelineOptions,
MemoryMonitorOptions
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 @@ public interface SdkHarnessOptions extends PipelineOptions,
MemoryMonitorOptions
* 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 interface SdkHarnessOptions extends PipelineOptions,
MemoryMonitorOptions
* 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 interface SdkHarnessOptions extends PipelineOptions,
MemoryMonitorOptions
* 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 interface SdkHarnessOptions extends PipelineOptions,
MemoryMonitorOptions
*/
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static SdkHarnessLogLevelOverrides from(Map<String, String> values)
{
- checkNotNull(values, "Expected values to be not null.");
+ checkArgumentNotNull(values, "Expected values to be not null.");
SdkHarnessLogLevelOverrides overrides = new
SdkHarnessLogLevelOverrides();
for (Map.Entry<String, String> 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 54b31a252b9..9cfedd42c77 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 @@ public interface ValueProvider<T> extends Serializable {
private transient volatile T cachedValue;
NestedValueProvider(ValueProvider<X> value, SerializableFunction<X, T>
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 interface ValueProvider<T> extends Serializable {
@SuppressWarnings("unchecked")
ValueProvider<T> result = (ValueProvider<T>)
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 @@ public interface ValueProvider<T> extends Serializable {
@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 interface ValueProvider<T> extends Serializable {
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 e88dab7eb2a..d1c9f957881 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 class ValueProviders {
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 0f23f32a269..9c96ff78625 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}" - <<UserSpecificDocker
FROM beam-build
RUN rm -f /var/log/faillog /var/log/lastlog
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
-RUN groupmod -g ${DOCKER_GROUP_ID} docker
+#RUN groupmod -g ${DOCKER_GROUP_ID} docker
RUN useradd -g ${GROUP_ID} -G docker -u ${USER_ID} -k /root -m ${USER_NAME} -d
"${DOCKER_HOME_DIR}"
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" >
"/etc/sudoers.d/beam-build-${USER_ID}"
ENV HOME "${DOCKER_HOME_DIR}"