Uploaded image for project: 'Spring Batch'
  1. Spring Batch
  2. BATCH-1777

org.springframework.batch.core.converter.DefaultJobParametersConverter not safe for use with certain Locales

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.1.9
    • Component/s: Core
    • Labels:
      None

      Description

      if you run the tests for org.springframework.batch.core.converter.DefaultJobParametersConverter on a machine with Locale.GERMAN

      testGetParametersWithNumberFormat (uses "value(long)=1,000")
      and
      testGetParametersWithDouble (uses "value(double)=1.38")

      will fail because of Locale problems
      (same applies to org.springframework.batch.core.step.job.DefaultJobParametersExtractorJobParametersTests testGetNamedDoubleJobParameters (uses "foo(double)=11.1"
      which uses the Converter under the hood)

      i would not call this a bug, because it would be a real hassle to solve the Locale problems for all Possibilities

      but maybe you could improve the Default..Converter to make it possible to set the locale and include following code
      for the NumberFormat instance

      // property locale or default
      NumberFormat f = NumberFormat.getInstance(Locale.getDefault());
      // getInstance might return a DecimalFormat, depends on Locale
      if (f instanceof DecimalFormat)

      { Double result = ((DecimalFormat) f).parse(value).doubleValue(); }

      // some fallback code

      the current JUnit tests would need an improvement too

      factory.setLocale(Locale.UK) // or .US

        Attachments

          Activity

            People

            • Assignee:
              david_syer Dave Syer
              Reporter:
              daywalker2000@gmx.net Michael Pralow
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: