Skip to content

Commit 101e8ed

Browse files
committed
8372609: Bug4944439 does not enforce locale correctly
Backport-of: 45c0600
1 parent 0a3249c commit 101e8ed

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

test/jdk/java/text/Format/NumberFormat/Bug4944439.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,22 +23,19 @@
2323

2424
/*
2525
* @test
26-
* @bug 4944439
26+
* @bug 4944439 8372609
2727
* @summary Confirm that numbers where all digits after the decimal separator are 0
2828
* and which are between Long.MIN_VALUE and Long.MAX_VALUE are returned
2929
* as Long(not double).
3030
* @run junit Bug4944439
3131
*/
3232

33-
import java.text.DecimalFormat;
33+
import java.text.NumberFormat;
3434
import java.util.ArrayList;
3535
import java.util.Locale;
3636
import java.util.stream.Stream;
3737

38-
import org.junit.jupiter.api.AfterAll;
39-
import org.junit.jupiter.api.BeforeAll;
4038
import org.junit.jupiter.params.ParameterizedTest;
41-
import org.junit.jupiter.params.provider.Arguments;
4239
import org.junit.jupiter.params.provider.MethodSource;
4340

4441
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -47,21 +44,7 @@
4744

4845
public class Bug4944439 {
4946

50-
// Save JVM default locale
51-
private static final Locale savedLocale = Locale.getDefault();
52-
private static final DecimalFormat df = new DecimalFormat();
53-
54-
// Set JVM default locale to US for testing
55-
@BeforeAll
56-
static void initAll() {
57-
Locale.setDefault(Locale.US);
58-
}
59-
60-
// Restore JVM default locale
61-
@AfterAll
62-
static void tearDownAll() {
63-
Locale.setDefault(savedLocale);
64-
}
47+
private static final NumberFormat df = NumberFormat.getInstance(Locale.US);
6548

6649
// Check return type and value returned by DecimalFormat.parse() for longs
6750
@ParameterizedTest

0 commit comments

Comments
 (0)