LuciferYang commented on code in PR #51926:
URL: https://github.com/apache/spark/pull/51926#discussion_r2262482764


##########
common/network-common/src/main/java/org/apache/spark/network/crypto/AuthEngine.java:
##########
@@ -61,10 +62,8 @@ class AuthEngine implements Closeable {
   private TransportCipher sessionCipher;
 
   AuthEngine(String appId, String preSharedSecret, TransportConf conf) {
-    Preconditions.checkNotNull(appId);
-    Preconditions.checkNotNull(preSharedSecret);
-    this.appId = appId;
-    this.preSharedSecret = preSharedSecret.getBytes(UTF_8);
+    this.appId = Objects.requireNonNull(appId);

Review Comment:
   ```
   /**
        * Checks that the specified object reference is not {@code null}. This
        * method is designed primarily for doing parameter validation in methods
        * and constructors, as demonstrated below:
        * <blockquote><pre>
        * public Foo(Bar bar) {
        *     this.bar = Objects.requireNonNull(bar);
        * }
        * </pre></blockquote>
        *
        * @param obj the object reference to check for nullity
        * @param <T> the type of the reference
        * @return {@code obj} if not {@code null}
        * @throws NullPointerException if {@code obj} is {@code null}
        */
       @ForceInline
       public static <T> T requireNonNull(T obj) {
           if (obj == null)
               throw new NullPointerException();
           return obj;
       }
   ```
   
   If the check succeeds, we can directly use the returned value without 
splitting it into two steps.
   
   



-- 
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]

Reply via email to