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

Re-examine FilterInputStream mark/reset

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      Synchronization of these methods is not part of their contract.

      Changing the long-standing behavior is not expected to affect user-defined subclasses.
      Show
      Synchronization of these methods is not part of their contract. Changing the long-standing behavior is not expected to affect user-defined subclasses.
    • Java API
    • Implementation

      Summary

      In the java.io package, remove the synchronized keyword from the mark(int) and reset() methods of the InputStream and FilterInputStream classes.

      Problem

      For the indicated methods, the synchronized keyword does not appear to add any value.

      Solution

      Remove the synchronized keyword from the declarations of the indicated methods.

      Specification

      --- a/src/java.base/share/classes/java/io/FilterInputStream.java
      +++ b/src/java.base/share/classes/java/io/FilterInputStream.java
      @@ -204,7 +204,7 @@ public class FilterInputStream extends InputStream {
            * @see     java.io.FilterInputStream#reset()
            */
           @Override
      -    public synchronized void mark(int readlimit) {
      +    public void mark(int readlimit) {
               in.mark(readlimit);
           }
      
      @@ -230,7 +230,7 @@ public class FilterInputStream extends InputStream {
            * @see        java.io.FilterInputStream#mark(int)
            */
           @Override
      -    public synchronized void reset() throws IOException {
      +    public void reset() throws IOException {
               in.reset();
           }
      
      --- a/src/java.base/share/classes/java/io/InputStream.java
      +++ b/src/java.base/share/classes/java/io/InputStream.java
      @@ -683,7 +683,7 @@ public abstract class InputStream implements Closeable {
            *                      the mark position becomes invalid.
            * @see     java.io.InputStream#reset()
            */
      -    public synchronized void mark(int readlimit) {}
      +    public void mark(int readlimit) {}
      
           /**
            * Repositions this stream to the position at the time the
      @@ -729,7 +729,7 @@ public abstract class InputStream implements Closeable {
            * @see     java.io.InputStream#mark(int)
            * @see     java.io.IOException
            */
      -    public synchronized void reset() throws IOException {
      +    public void reset() throws IOException {
               throw new IOException("mark/reset not supported");
           }

            bpb Brian Burkhalter
            alanb Alan Bateman
            Alan Bateman, Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: