hadoop-hdfs-issues mailing list archives

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

     [ https://issues.apache.org/jira/browse/HDFS-10329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lin Yiqun updated HDFS-10329:
-----------------------------
    Attachment: HDFS-10329.001.patch

> 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
>            Assignee: Lin Yiqun
>            Priority: Minor
>         Attachments: HDFS-10329.001.patch
>
>
> 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