-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2
-
b02
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2213696 | 8 | Xueming Shen | P3 | Closed | Fixed | b06 |
JDK-2209940 | 7u2 | Xueming Shen | P4 | Closed | Fixed | b08 |
JDK-2209974 | 6u30 | Sean Coffey | P3 | Closed | Fixed | b08 |
JDK-2209973 | 5.0u33 | Sean Coffey | P3 | Closed | Fixed | b08 |
Charset cache access method, lookup() needs to be synchronized.
One lookup() had been already done as the fix for 4685305.
Considering to the purpose of the above resolution,
one more lookup() should be synchronized as well.
Specifically speaking, the line#182 should be synchronized.
=== ./jdk/share/classes/sun/nio/cs/AbstractCharsetProvider.java (jdk7b75)===
....
¿ 158 public final Charset charsetForName(String charsetName) {
¿ 159 synchronized (this) { <===== This is the fix for 4685305
¿ 160 init();
¿ 161 return lookup(canonicalize(charsetName));
¿ 162 }
¿ 163 }
¿ 164
165 public final Iterator<Charset> charsets() {
166
167 final ArrayList ks;
168 synchronized (this) {
169 init();
170 ks = new ArrayList(classMap.keySet());
171 }
172
173 return new Iterator<Charset>() {
174 Iterator i = ks.iterator();
175
176 public boolean hasNext() {
177 return i.hasNext();
178 }
179
180 public Charset next() {
181 String csn = (String)i.next();
182 return lookup(csn); <====== Should this line be synchronized ?
183 }
184
185 public void remove() {
186 throw new UnsupportedOperationException();
187 }
188 };
189 }
....
======================
One lookup() had been already done as the fix for 4685305.
Considering to the purpose of the above resolution,
one more lookup() should be synchronized as well.
Specifically speaking, the line#182 should be synchronized.
=== ./jdk/share/classes/sun/nio/cs/AbstractCharsetProvider.java (jdk7b75)===
....
¿ 158 public final Charset charsetForName(String charsetName) {
¿ 159 synchronized (this) { <===== This is the fix for 4685305
¿ 160 init();
¿ 161 return lookup(canonicalize(charsetName));
¿ 162 }
¿ 163 }
¿ 164
165 public final Iterator<Charset> charsets() {
166
167 final ArrayList ks;
168 synchronized (this) {
169 init();
170 ks = new ArrayList(classMap.keySet());
171 }
172
173 return new Iterator<Charset>() {
174 Iterator i = ks.iterator();
175
176 public boolean hasNext() {
177 return i.hasNext();
178 }
179
180 public Charset next() {
181 String csn = (String)i.next();
182 return lookup(csn); <====== Should this line be synchronized ?
183 }
184
185 public void remove() {
186 throw new UnsupportedOperationException();
187 }
188 };
189 }
....
======================
- backported by
-
JDK-2209973 (cs) Charset cache lookups should be synchronized
-
- Closed
-
-
JDK-2209974 (cs) Charset cache lookups should be synchronized
-
- Closed
-
-
JDK-2213696 (cs) Charset cache lookups should be synchronized
-
- Closed
-
-
JDK-2209940 (cs) Charset cache lookups should be synchronized
-
- Closed
-
- relates to
-
JDK-4685305 (cs) Charset.{forName,isSupported} not thread-safe
-
- Resolved
-
-
JDK-8012326 Deadlock occurs when Charset.availableCharsets() is called by several threads at the same time
-
- Closed
-
(1 relates to)