JDK-4168625 : inefficiency in java.util.ResourceBundle causes extra network traffic
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.1.5,1.1.6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-08-24
  • Updated: 2013-11-01
  • Resolved: 1999-06-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description

Name: chT40241			Date: 08/24/98


Found a bug in java.util.ResourceBundle; submitted to JavaSoft

Consider a call to java.util.ResourceBundle.getBundle("com.sas.Resources")
where the default locale is en_US
The only resource bundle that exists
is com/sas/Resources.properties

Tracing the network traffic (i.e. look at the Java console when running
an applet with the Java PlugIn 1.1[.1], you'll see the following network
reads occurring:

Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en_US.class no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en_US.properties no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en.class no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en.properties no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en_US.class no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en_US.properties no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en.class no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources_en.properties no proxy
Opening http://d133.us.sas.com/sasjavasoft/com/sas/Resources.class no proxy

that is, there are two attempted network reads each of

  com/sas/Resources_en_US.class
  com/sas/Resources_en_US.properties
  com/sas/Resources_en.class
  com/sas/Resources_en.properties

when there should only be one each.

Inspecting the JDK 1.1.6 code for ResourceBundle shows why.

ResourceBundle.getBundle(String baseName) calls
    getBundle(baseName,Locale.getDefault(),getLoader())
which calls 
    findBundle(baseName,Locale.getDefault(),getLoader(),false)
and if that fails, turns around and calls
    findBundle(baseName,Locale.getDefault(),getLoader(),true)

findBundle(...,false) tries to find the resource (i.e. com.sas.Resources)
via the passed in Locale "en_US" and "en", and fails, then 
findBundle(...,true) tries to find the resource (i.e. com.sas.Resources)
via the passed in Locale "en_US" and "en", and then finally
by no locale, and finally finds it.

Further, findBundle(...,false) does *not* mark com.sas.Resources_en_US and
com.sas.Resources_en as NOTFOUND,
so in the call to findBundle(...,true) it retries
com.sas.Resources_en_US and com.sas.Resources_en again (and fails)
and only when it finds com/sas/Resources.properties does it
mark com.sas.Resources_en_US and com.sas.Resources_en as NOTFOUND.

This causes much unecessary network traffic when loading resource
bundles, especially when the default resource bundle matches
the en_US locale, but there is no corresponding en_US .properties file.

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel FIXED IN: kestrel-beta INTEGRATED IN: kestrel-beta
14-06-2004

EVALUATION Pseudo-evaluation so we can mark this committed.
11-06-2004