[ 
https://issues.apache.org/jira/browse/HADOOP-17126?focusedWorklogId=602382&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-602382
 ]

ASF GitHub Bot logged work on HADOOP-17126:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/May/21 14:52
            Start Date: 26/May/21 14:52
    Worklog Time Spent: 10m 
      Work Description: amahussein commented on a change in pull request #3050:
URL: https://github.com/apache/hadoop/pull/3050#discussion_r639805392



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Validate.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import java.util.function.Supplier;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * <p>This class replaces {@code guava.Preconditions} which provides helpers
+ * to validate the following conditions:
+ * <ul>
+ *   <li>An invalid {@code null} obj causes a {@link 
NullPointerException}.</li>
+ *   <li>An invalid argument causes an {@link IllegalArgumentException}.</li>
+ *   <li>An invalid state causes an {@link IllegalStateException}.</li>
+ *   <li>An invalid index causes an {@link IndexOutOfBoundsException}.</li>
+ * </ul>
+ */
[email protected]
[email protected]
+public final class Validate {

Review comment:
       Sounds like a good idea. I will rename the class.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 602382)
    Time Spent: 1h 40m  (was: 1.5h)

> implement non-guava Precondition checkNotNull
> ---------------------------------------------
>
>                 Key: HADOOP-17126
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17126
>             Project: Hadoop Common
>          Issue Type: Sub-task
>            Reporter: Ahmed Hussein
>            Assignee: Ahmed Hussein
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HADOOP-17126.001.patch, HADOOP-17126.002.patch
>
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> As part In order to replace Guava Preconditions, we need to implement our own 
> versions of the API.
>  This Jira is to create {{checkNotNull}} in a new package dubbed {{unguava}}.
>  +The plan is as follows+
>  * create a new {{package org.apache.hadoop.util.unguava;}}
>  * {{create class Validate}}
>  * implement  {{package org.apache.hadoop.util.unguava.Validate;}} with the 
> following interface
>  ** {{checkNotNull(final T obj)}}
>  ** {{checkNotNull(final T reference, final Object errorMessage)}}
>  ** {{checkNotNull(final T obj, final String message, final Object... 
> values)}}
>  ** {{checkNotNull(final T obj,final Supplier<String> msgSupplier)}}
>  * {{guava.preconditions used String.lenientformat which suppressed 
> exceptions caused by string formatting of the exception message . So, in 
> order to avoid changing the behavior, the implementation catches Exceptions 
> triggered by building the message (IllegalFormat, InsufficientArg, 
> NullPointer..etc)}}
>  * {{After merging the new class, we can replace 
> guava.Preconditions.checkNotNull by {{unguava.Validate.checkNotNull}}}}
>  * We need the change to go into trunk, 3.1, 3.2, and 3.3
>  
> Similar Jiras will be created to implement checkState, checkArgument, 
> checkIndex



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to