8336300: DateFormatSymbols#getInstanceRef returns non-cached instance
Reviewed-by: joehw, iris, jlu, aturbanov
This commit is contained in:
parent
7ec55df34a
commit
10186ff48f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -351,20 +351,6 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
||||
throw new RuntimeException("DateFormatSymbols instance creation failed.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a DateFormatSymbols provided by a provider or found in
|
||||
* the cache. Note that this method returns a cached instance,
|
||||
* not its clone. Therefore, the instance should never be given to
|
||||
* an application.
|
||||
*/
|
||||
static final DateFormatSymbols getInstanceRef(Locale locale) {
|
||||
DateFormatSymbols dfs = getProviderInstance(locale);
|
||||
if (dfs != null) {
|
||||
return dfs;
|
||||
}
|
||||
throw new RuntimeException("DateFormatSymbols instance creation failed.");
|
||||
}
|
||||
|
||||
private static DateFormatSymbols getProviderInstance(Locale locale) {
|
||||
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
|
||||
DateFormatSymbolsProvider provider = adapter.getDateFormatSymbolsProvider();
|
||||
|
@ -623,7 +623,7 @@ public class SimpleDateFormat extends DateFormat {
|
||||
|
||||
initializeCalendar(locale);
|
||||
this.pattern = pattern;
|
||||
this.formatData = DateFormatSymbols.getInstanceRef(locale);
|
||||
formatData = DateFormatSymbols.getInstance(locale);
|
||||
this.locale = locale;
|
||||
initialize(locale);
|
||||
}
|
||||
@ -644,7 +644,7 @@ public class SimpleDateFormat extends DateFormat {
|
||||
}
|
||||
|
||||
this.pattern = pattern;
|
||||
this.formatData = (DateFormatSymbols) formatSymbols.clone();
|
||||
formatData = (DateFormatSymbols) formatSymbols.clone();
|
||||
this.locale = Locale.getDefault(Locale.Category.FORMAT);
|
||||
initializeCalendar(this.locale);
|
||||
initialize(this.locale);
|
||||
|
Loading…
Reference in New Issue
Block a user