[
https://issues.apache.org/jira/browse/HDFS-13313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16406809#comment-16406809
]
ASF GitHub Bot commented on HDFS-13313:
---------------------------------------
Github user glglwty commented on a diff in the pull request:
https://github.com/apache/hadoop/pull/355#discussion_r175872822
--- Diff:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java
---
@@ -3826,11 +3826,7 @@ void fromXml(Stanza st) throws InvalidXmlException {
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("AddCacheDirectiveInfo [");
- builder.append("id=" + directive.getId() + ",");
- builder.append("path=" + directive.getPath().toUri().getPath() +
",");
- builder.append("replication=" + directive.getReplication() + ",");
- builder.append("pool=" + directive.getPool() + ",");
- builder.append("expiration=" +
directive.getExpiration().getMillis());
+ builder.append(directive);
--- End diff --
String "null" will be appended to the StringBuilder
> 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]