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

MemoryCacheImageInputStream.flushBefore(long) throws unexpected exception

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: mlR10151 Date: 04/04/2001



      The spec for the MemoryCacheImageInputStream.flushBefore(long pos)
      says nothing about throwing IndexOutOfBoundsException if attempt to
      "flushBefore" a flushed position.

      But it throws the IndexOutOfBoundsException, saying that "pos already disposed" in the following
      case:

      ===================== a.java =======================
      import java.io.*;
      import javax.imageio.stream.*;

      public class a {
          public static void main (String argv[]) throws Exception {
              byte[] ba = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
              InputStream istream = new ByteArrayInputStream(ba);
              MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(istream);

              mciis.flushBefore(Long.MAX_VALUE);

              System.out.println("Passed");
          }
      }
      ===================== log =======================
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b58)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b58, mixed mode)
      Exception in thread "main" java.lang.IndexOutOfBoundsException: pos already disposed
              at javax.imageio.stream.MemoryCache.disposeBefore(MemoryCache.java:300)
              at
      javax.imageio.stream.MemoryCacheImageInputStream.flushBefore(MemoryCacheImageInputStream.java:94)
              at a.main(a.java:10)


      This bug causes failure of the new JCK test
      api/javax_imageio/stream/MemoryCacheImageInputStream/index.html#flush



      Note, that if I really try to flush a flushed position, for example by
          mciis.flushBefore(5);
          mciis.flushBefore(4);
      it does not throw any exception.


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

            dricesunw Daniel Rice (Inactive)
            mlsunw Ml Ml (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: