hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Siwakorn Srisakaokul (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HBASE-10407) String Format Exception
Date Thu, 23 Jan 2014 16:38:37 GMT
Siwakorn Srisakaokul created HBASE-10407:
--------------------------------------------

             Summary: String Format Exception
                 Key: HBASE-10407
                 URL: https://issues.apache.org/jira/browse/HBASE-10407
             Project: HBase
          Issue Type: Bug
          Components: hadoop2
    Affects Versions: 0.99.0
            Reporter: Siwakorn Srisakaokul
            Priority: Trivial


There is a bug in {{hbase/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java:91/92}}.
 When the parameter {{name}} contains a %, it will cause a format exception by String.Format(...).

*Here is a simple patch to fix it*

{code:title=hbase.patch|borderStyle=solid}
>From 43a4b247f5ac69f57264b2c1b20dcca8205514c4 Mon Sep 17 00:00:00 2001
From: Siwakorn Srisakaokul <sping128@gmail.com>
Date: Wed, 22 Jan 2014 10:09:26 -0800
Subject: [PATCH] Format Patch

---
 .../org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java
index b01f88b..c399323 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricMutableQuantiles.java
@@ -82,14 +82,12 @@ public class MetricMutableQuantiles extends MutableMetric implements MetricHisto
         "Number of %s for %s with %ds interval", lsName, desc, interval));
     // Construct the MetricsInfos for the quantiles, converting to percentiles
     quantileInfos = new MetricsInfo[quantiles.length];
-    String nameTemplate = ucName + "%dthPercentile" + interval + "sInterval"
-        + uvName;
-    String descTemplate = "%d percentile " + lvName + " with " + interval
-        + " second interval for " + desc;
+    String nameTemplate = "%s%dthPercentile%dsInterval%s";
+    String descTemplate = "%d percentile %s with %d second interval for %s";
     for (int i = 0; i < quantiles.length; i++) {
       int percentile = (int) (100 * quantiles[i].quantile);
-      quantileInfos[i] = info(String.format(nameTemplate, percentile),
-          String.format(descTemplate, percentile));
+      quantileInfos[i] = info(String.format(nameTemplate, ucName, percentile, interval, uvName),
+          String.format(descTemplate, percentile, lvName, interval, desc));
     }
 
     estimator = new MetricSampleQuantiles(quantiles);
-- 
1.8.5.2
{code}




--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message