LuciferYang opened a new pull request #33991:
URL: https://github.com/apache/spark/pull/33991
### What changes were proposed in this pull request?
Java 8 provides the java.util.Objects, this pr it to replace some Guava API
usages with the same semantics, the replacement rules are as follows:
1. Preconditions.checkNotNull -> Objects.requireNonNull
**Guava**
```
public static <T> T checkNotNull(T reference,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
if (reference == null) {
// If either of these parameters is null, the right thing happens
anyway
throw new NullPointerException(
format(errorMessageTemplate, errorMessageArgs));
}
return reference;
}
```
**java.util.Objects**
```
public static <T> T requireNonNull(T obj, Supplier<String>
messageSupplier) {
if (obj == null)
throw new NullPointerException(messageSupplier.get());
return obj;
}
```
2. Objects.hashCode -> j.u.Objects.hash
**Guava**
```
public static int hashCode(@Nullable Object... objects) {
return java.util.Arrays.hashCode(objects);
}
```
**java.util.Objects**
```
public static int hash(Object... values) {
return java.util.Arrays.hashCode(values);
}
```
3. Objects.equal -> j.u.Objects.equals
**Guava**
```
public static boolean equal(@Nullable Object a, @Nullable Object b) {
return a == b || (a != null && a.equals(b));
}
```
**java.util.Objects**
```
public static boolean equals(Object a, Object b) {
return (a == b) || (a != null && a.equals(b));
}
```
### Why are the changes needed?
Reduce dependence on Guava API because Spark still use Guava 14.0.1.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Pass the Jenkins or GitHub Action
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]