Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-10407

String Format Exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.99.0
    • Fix Version/s: 0.99.0
    • Component/s: hadoop2
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      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

      hbase.patch
      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
      

        Attachments

        1. hbase.patch
          2 kB
          Michael Stack
        2. hbase.patch
          2 kB
          Siwakorn Srisakaokul

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ping128 Siwakorn Srisakaokul
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: