[
https://issues.apache.org/jira/browse/HDFS-13313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16405319#comment-16405319
]
ASF GitHub Bot commented on HDFS-13313:
---------------------------------------
GitHub user glglwty opened a pull request:
https://github.com/apache/hadoop/pull/355
HDFS-13313. Fix NullPointerException in FSEditLogOp.toString().
In some subclasses of FSEditLogOp, toString() uses dot(.) operator on
some fields. Those fields could be set to null by resetSubFields() and a
NullPointerException would be thrown in toString(). This patch fixes
this bug by calling StringBuilder.append(field). Thus "null" would be
printed in the field=null case, and field.toString() code is properly
reused to avoid repetition.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/glglwty/hadoop fix-null-pointer-tostring
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/hadoop/pull/355.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #355
----
commit 704f6cbbddac55f59d8ea560d8567d5756a196df
Author: Tianyi Wang <twang@...>
Date: 2018-03-19T19:15:04Z
HDFS-13313: Fix NullPointerException in FSEditLogOp.toString()
In some subclasses of FSEditLogOp, toString() uses dot(.) operator on
some fields. Those fields could be set to null by resetSubFields() and a
NullPointerException would be thrown in toString(). This patch fixes
this bug by calling StringBuilder.append(field). Thus "null" would be
printed in the field=null case, and field.toString() code is properly
reused to avoid repetition.
----
> FSEditLogOp.toString() throws NullPointerException
> --------------------------------------------------
>
> Key: HDFS-13313
> URL: https://issues.apache.org/jira/browse/HDFS-13313
> Project: Hadoop HDFS
> Issue Type: Bug
> Affects Versions: 3.0.2
> Reporter: Tianyi Wang
> Priority: Minor
>
> In some subclasses of FSEditLogOp, toString() [uses dot (.) operator on some
> could-be-null
> fields|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L3896].
> Those fields could be set to null by
> [resetSubFields()|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L3857].
> This error can be hit by turning on debug logging: toString() is called in
> [FSEditLogAsync.logSync()|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java#L128]
> with debug logging and reset() is called in
> [doEditTransaction()|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java#L484]
> when the operation is executed asynchronously.
> Proposed change: Avoid "field of field" access in toString() and use
> StringBuilder.append(field) because those fields have toString() themselves,
> and it would append "null" to the string if 'field' is null.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]