You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "Max Schaefer (JIRA)" <ji...@apache.org> on 2016/04/26 13:18:13 UTC
[jira] [Created] (HDFS-10329) Bad initialisation of StringBuffer in
RequestHedgingProxyProvider.java
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)