United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6907974 : (cs) Charset.availableCharsets throws NPE if "non-standard" charset is not present

Details
Type:
Bug
Submit Date:
2009-12-07
Status:
Closed
Updated Date:
2012-10-22
Project Name:
JDK
Resolved Date:
2012-10-22
Component:
core-libs
OS:
generic
Sub-Component:
java.nio.charsets
CPU:
generic
Priority:
P4
Resolution:
Won't Fix
Affected Versions:
7
Fixed Versions:
8

Related Reports
Relates:

Sub Tasks

Description
Charset.availableCharsets throws NullPointerException if any of the charsets listed in StandardCharsets is not present (all "standard" charsets, as listed in java.nio.charset.Charsets, are persent)

/opt/my/usg169/space/export/xxx/build/tests/image/bin/java 
AvailableCharsetNames
Exception in thread "main" java.lang.NullPointerException
       at java.nio.charset.Charset.put(Charset.java:549)
       at java.nio.charset.Charset.access$300(Charset.java:272)
       at java.nio.charset.Charset$4.run(Charset.java:587)
       at java.nio.charset.Charset$4.run(Charset.java:582)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.nio.charset.Charset.availableCharsets(Charset.java:581)
       at AvailableCharsetNames.main(AvailableCharsetNames.java:17)

Should I be expecting at least "US-ASCII" as one of the entries in 
availableCharsets() ?

                                    

Comments
EVALUATION

The issue is that sun.nio.cs.FastCharsetProvider#charsets returns an Iterator that doesn't handle missing charsets. If a charset is not present then the next method will return null.
                                     
2009-12-07
PUBLIC COMMENTS

http://netbeans.org/bugzilla/show_bug.cgi?id=198827
                                     
2011-05-25



Hardware and Software, Engineered to Work Together