Skip to content

Commit 10186ff

Browse files
committed
8336300: DateFormatSymbols#getInstanceRef returns non-cached instance
Reviewed-by: joehw, iris, jlu, aturbanov
1 parent 7ec55df commit 10186ff

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/java.base/share/classes/java/text/DateFormatSymbols.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, 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
@@ -351,20 +351,6 @@ public static final DateFormatSymbols getInstance(Locale locale) {
351351
throw new RuntimeException("DateFormatSymbols instance creation failed.");
352352
}
353353

354-
/**
355-
* Returns a DateFormatSymbols provided by a provider or found in
356-
* the cache. Note that this method returns a cached instance,
357-
* not its clone. Therefore, the instance should never be given to
358-
* an application.
359-
*/
360-
static final DateFormatSymbols getInstanceRef(Locale locale) {
361-
DateFormatSymbols dfs = getProviderInstance(locale);
362-
if (dfs != null) {
363-
return dfs;
364-
}
365-
throw new RuntimeException("DateFormatSymbols instance creation failed.");
366-
}
367-
368354
private static DateFormatSymbols getProviderInstance(Locale locale) {
369355
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
370356
DateFormatSymbolsProvider provider = adapter.getDateFormatSymbolsProvider();

src/java.base/share/classes/java/text/SimpleDateFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public SimpleDateFormat(String pattern, Locale locale)
623623

624624
initializeCalendar(locale);
625625
this.pattern = pattern;
626-
this.formatData = DateFormatSymbols.getInstanceRef(locale);
626+
formatData = DateFormatSymbols.getInstance(locale);
627627
this.locale = locale;
628628
initialize(locale);
629629
}
@@ -644,7 +644,7 @@ public SimpleDateFormat(String pattern, DateFormatSymbols formatSymbols)
644644
}
645645

646646
this.pattern = pattern;
647-
this.formatData = (DateFormatSymbols) formatSymbols.clone();
647+
formatData = (DateFormatSymbols) formatSymbols.clone();
648648
this.locale = Locale.getDefault(Locale.Category.FORMAT);
649649
initializeCalendar(this.locale);
650650
initialize(this.locale);

0 commit comments

Comments
 (0)