hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Schaefer (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HDFS-10329) Bad initialisation of StringBuffer in RequestHedgingProxyProvider.java
Date Tue, 26 Apr 2016 11:18:13 GMT
Max Schaefer created HDFS-10329:
-----------------------------------

             Summary: Bad initialisation of StringBuffer in RequestHedgingProxyProvider.java
                 Key: HDFS-10329
                 URL: https://issues.apache.org/jira/browse/HDFS-10329
             Project: Hadoop HDFS
          Issue Type: Bug
          Components: ha
            Reporter: Max Schaefer
            Priority: Minor


On [line 167|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/RequestHedgingProxyProvider.java#L167]
of {{RequestHedgingProxyProvider.java}}, a {{StringBuilder}} is initialised like this:

{code}
StringBuilder combinedInfo = new StringBuilder('[');
{code}

This won't have the (presumably) desired effect of creating a {{StringBuilder}} containing
the string {{"["}}; instead, it will create a {{StringBuilder}} with capacity 91 (the character
code of '['). See [here|http://what-when-how.com/Tutorial/topic-90315a/Java-Puzzlers-Traps-Pitfalls-and-Corner-Cases-69.html]
for an explanation.

To fix this, pass a string literal instead of the character literal:

{code}
StringBuilder combinedInfo = new StringBuilder("[");
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message