You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "FuzzingTeam (Jira)" <ji...@apache.org> on 2022/10/22 10:17:00 UTC

[jira] [Commented] (HADOOP-18504) An unhandled NullPointerException in class KeyProvider

    [ https://issues.apache.org/jira/browse/HADOOP-18504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17622596#comment-17622596 ] 

FuzzingTeam commented on HADOOP-18504:
--------------------------------------

The aforementioned exception originates in the method *getBaseName* when the code tries to find the index of the last occurrence of '@' in the null input string {*}versionName{*}.

 

{*}Code snippet of where the NPE throws:{*}{*}{*}
{code:java}
public static String getBaseName(String versionName) throws IOException {
  int div = versionName.lastIndexOf('@');                               // <--- thrown here
  if (div == -1) {
    throw new IOException("No version in key path " + versionName);
  }
  return versionName.substring(0, div);
}{code}
*Solution:*

We propose adding a null check for the input string and throwing an IOException with a proper error message.

We also propose fixing the Javadoc comment for this method which demonstrates an incorrect example.

 

*Code snippet of the comment with buggy example:*
{code:java}
 /**
 * Split the versionName in to a base name. Converts "/aaa/bbb/3" to
 * "/aaa/bbb".
 ...
 */ {code}

>  An unhandled NullPointerException in class KeyProvider
> -------------------------------------------------------
>
>                 Key: HADOOP-18504
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18504
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 3.3.4
>            Reporter: FuzzingTeam
>            Priority: Major
>              Labels: pull-request-available
>
> The code throws an unhandled NullPointerException when the method *getBaseName* of KeyProvider.java is called with a null as input.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org