Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6898310

(cs) Charset cache lookups should be synchronized

    XMLWordPrintable

Details

    • b02
    • generic
    • generic
    • Not verified

    Backports

      Description

        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 }
        ....
        ======================

        Attachments

          Issue Links

            Activity

              People

                coffeys Sean Coffey
                tbaba Tadayuki Baba (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: