[ https://issues.apache.org/jira/browse/HADOOP-17126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17218506#comment-17218506 ]
Ahmed Hussein commented on HADOOP-17126: ---------------------------------------- {quote}I don't want the overhead of either a lambda or a string when testing for a condition that should rarely if ever happen. {quote} The patch is not introducing that overhead. The overhead of the constructing the arguments is the responsibility of the caller, right? If the {{Vararg}} is passed by the caller expecting that the string is evaluated by {{Preconditions}}, then it should be handled by the {{callee}}. Of course, unless we go through the entire code and change the arguments sent to the {{Preconditions.checkNotNull}}. {quote}Preconditions is under the Apache License so why not copy it to org.apache.hadoop.util.Preconditions and just remove the unnecessary annotation imports?{quote} I checked that option. {{org.apache.hadoop.util.Preconditions}} has a different behavior/signatures compared to guava preconditions. It would break the code. > 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 > Attachments: HADOOP-17126.001.patch, HADOOP-17126.002.patch > > > 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: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org