Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37329

Bug in StatsMath.java DecimalFormat

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The implementation in statsmath.java results in an NumberFormatException when then LANG for the VM is set to another than EN:

      Caused by: java.lang.NumberFormatException: For input string: "19,16"
      at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
      at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
      at java.lang.Double.parseDouble(Double.java:538)
      at java.lang.Double.valueOf(Double.java:502)
      at jenkins.plugins.build_metrics.stats.StatsMath.roundTwoDecimals(StatsMath.java:13)
      at jenkins.plugins.build_metrics.stats.StatsMath.getPercent(StatsMath.java:8)
      at jenkins.plugins.build_metrics.stats.StatsFactory.getFailureRate(StatsFactory.java:167)
      ... 135 more

      Please change:
      public static double roundTwoDecimals(double iVal)

      { DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double.valueOf(twoDForm.format(iVal)); }

      to:
      public static double roundTwoDecimals(double iVal)

      { DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.getDefault()); DecimalFormat twoDForm = new DecimalFormat("#"+decimalFormatSymbols.getDecimalSeparator()+"##",decimalFormatSymbols); return Double.valueOf(twoDForm.format(iVal)); }

      Thanks

        Attachments

          Activity

          Hide
          px3 Rolf Rother added a comment -

          Fixed and will be included in the next release

          Show
          px3 Rolf Rother added a comment - Fixed and will be included in the next release
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Rolf Rother
          Path:
          src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java
          http://jenkins-ci.org/commit/build-metrics-plugin/20d0608baaf25b94d5f13b3cd64bf6c1cc246d36
          Log:
          [FIXED JENKINS-37329] Fixed DecimalFormat problem with VM language
          settings other than EN

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Rolf Rother Path: src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java http://jenkins-ci.org/commit/build-metrics-plugin/20d0608baaf25b94d5f13b3cd64bf6c1cc246d36 Log: [FIXED JENKINS-37329] Fixed DecimalFormat problem with VM language settings other than EN
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Rolf Rother
          Path:
          src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java
          src/test/java/jenkins/plugins/build_metrics/stats/StatsMathTest.java
          http://jenkins-ci.org/commit/build-metrics-plugin/f22fe982feb30c5566eb665b423a6bb2806ed022
          Log:
          JENKINS-37329 - Changed caluclation of RoundDecimal again.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Rolf Rother Path: src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java src/test/java/jenkins/plugins/build_metrics/stats/StatsMathTest.java http://jenkins-ci.org/commit/build-metrics-plugin/f22fe982feb30c5566eb665b423a6bb2806ed022 Log: JENKINS-37329 - Changed caluclation of RoundDecimal again.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Rolf Rother
          Path:
          src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java
          src/test/java/jenkins/plugins/build_metrics/stats/StatsMathTest.java
          http://jenkins-ci.org/commit/build-metrics-plugin/b4486c4ae1a216e48029d36708c9fcb47be2f4f3
          Log:
          Revert "JENKINS-37329 - Changed caluclation of RoundDecimal again."

          This reverts commit f22fe982feb30c5566eb665b423a6bb2806ed022.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Rolf Rother Path: src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java src/test/java/jenkins/plugins/build_metrics/stats/StatsMathTest.java http://jenkins-ci.org/commit/build-metrics-plugin/b4486c4ae1a216e48029d36708c9fcb47be2f4f3 Log: Revert " JENKINS-37329 - Changed caluclation of RoundDecimal again." This reverts commit f22fe982feb30c5566eb665b423a6bb2806ed022.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Rolf Rother
          Path:
          src/main/java/jenkins/plugins/build_metrics/stats/StatsFactory.java
          src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java
          src/main/java/jenkins/plugins/build_metrics/stats/StatsModel.java
          src/main/resources/jenkins/plugins/build_metrics/BuildMetricsPlugin/BuildStats.jelly
          http://jenkins-ci.org/commit/build-metrics-plugin/8ace1d0873af1ae523ebc25d7c269bd7ba048de8
          Log:
          Revert "JENKINS-37329 - Changed caluclation of RoundDecimal again."

          This reverts commit f22fe982feb30c5566eb665b423a6bb2806ed022.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Rolf Rother Path: src/main/java/jenkins/plugins/build_metrics/stats/StatsFactory.java src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java src/main/java/jenkins/plugins/build_metrics/stats/StatsModel.java src/main/resources/jenkins/plugins/build_metrics/BuildMetricsPlugin/BuildStats.jelly http://jenkins-ci.org/commit/build-metrics-plugin/8ace1d0873af1ae523ebc25d7c269bd7ba048de8 Log: Revert " JENKINS-37329 - Changed caluclation of RoundDecimal again." This reverts commit f22fe982feb30c5566eb665b423a6bb2806ed022.

            People

            • Assignee:
              px3 Rolf Rother
              Reporter:
              px3 Rolf Rother
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: