Skip to content

[MINOR] Fix locale specific NumberFormatException in testutils …#7215

Merged
codope merged 1 commit intoapache:masterfrom
trushev:fix-locale
Dec 7, 2022
Merged

[MINOR] Fix locale specific NumberFormatException in testutils …#7215
codope merged 1 commit intoapache:masterfrom
trushev:fix-locale

Conversation

@trushev
Copy link
Contributor

@trushev trushev commented Nov 16, 2022

…HoodieTestDataGenerator

Change Logs

String.format is locale specific. Example:

if (Locale.getDefault() == ENGLISH) {
  assert String.format("%5f", 0.1f) == "0.100000"
}
if (Locale.getDefault() == GERMAN) {
  assert String.format("%5f", 0.1f) == "0,100000"
}

So default GERMAN locale leads to failure of new BigDecimal("0,100000") with exception NumberFormatException.
It is not convenient to develop when we have locale specific tests.

Impact

Fix NumberFormatException when default locale consists of comma as decimal separator

java.lang.NumberFormatException
	at java.math.BigDecimal.<init>(BigDecimal.java:501)
	at java.math.BigDecimal.<init>(BigDecimal.java:387)
	at java.math.BigDecimal.<init>(BigDecimal.java:813)
	at org.apache.hudi.common.testutils.HoodieTestDataGenerator.generateGenericRecord(HoodieTestDataGenerator.java:330)
	at org.apache.hudi.functional.TestBootstrap.lambda$generateTestRawTripDataset$14(TestBootstrap.java:576)
	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
	at java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:581)
	at org.apache.hudi.functional.TestBootstrap.generateTestRawTripDataset(TestBootstrap.java:574)
	at org.apache.hudi.functional.TestBootstrap.generateNewDataSetAndReturnSchema(TestBootstrap.java:165)
	at org.apache.hudi.functional.TestBootstrap.testBootstrapCommon(TestBootstrap.java:242)
	at org.apache.hudi.functional.TestBootstrap.testMetadataBootstrapNonpartitionedCOW(TestBootstrap.java:182)

Risk level

None

Documentation Update

None

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@nsivabalan
Copy link
Contributor

@trushev : hey can you rebase w/ latest master please.

@nsivabalan nsivabalan added the priority:blocker Production down; release blocker label Dec 6, 2022
@trushev
Copy link
Contributor Author

trushev commented Dec 6, 2022

@trushev : hey can you rebase w/ latest master please.

Thank you, it's rebased

@hudi-bot
Copy link
Collaborator

hudi-bot commented Dec 6, 2022

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@nsivabalan nsivabalan added priority:high Significant impact; potential bugs release-0.12.2 Patches targetted for 0.12.2 and removed priority:blocker Production down; release blocker labels Dec 6, 2022
@codope codope merged commit 6629bf7 into apache:master Dec 7, 2022
codope pushed a commit that referenced this pull request Dec 13, 2022
nsivabalan pushed a commit that referenced this pull request Dec 13, 2022
fengjian428 pushed a commit to fengjian428/hudi that referenced this pull request Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high Significant impact; potential bugs release-0.12.2 Patches targetted for 0.12.2

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants