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

JPEG native library not MT-safe.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.1, 1.3.1_03
    • Fix Version/s: 1.3.1_04
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      04
    • CPU:
      x86, sparc
    • OS:
      solaris_8, windows_2000

      Backports

        Description



        Name: gm110360 Date: 09/13/2001


        Both Windows 2000 & Linux

        java version "1.3.1"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
        Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


        This is a follow-up posting for the earlier filed bugs under Review ID 129807 &
        129845; I will just present new information and source demonstrating the issue,
        as all my old statements are still valid.

        The following application provokes the error under Windows2000 Java1.3.1 and,
        most interestingly, under Linux Java1.3.1 (2.2 kernel), where I haven't seen
        this error happen under normal circumstances so far. Due to my current schedule,
        I was not able to test it under Java1.4 or IBM JDK1.3 as I did earlier.

        ------

        import com.sun.image.codec.jpeg.JPEGCodec;
        import com.sun.image.codec.jpeg.JPEGEncodeParam;
        import com.sun.image.codec.jpeg.JPEGImageEncoder;
        import java.awt.image.BufferedImage;
        import java.io.IOException;
        import java.io.PipedInputStream;
        import java.io.PipedOutputStream;
        import java.io.OutputStream;


        class WriterThread implements Runnable
        {
        Thread thread;
        PipedOutputStream out;

        public WriterThread(PipedOutputStream postream)
        {
        out = postream;
        }

        public void start()
        {
        if (thread == null)
        {
        thread = new Thread(this, "WriterThread");
        thread.start();
        }
        }

        public void run()
        {
        try
        {
        // Do the stuff and write it.
        BufferedImage image = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
        JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(out);
        JPEGEncodeParam params = JPEGCodec.getDefaultJPEGEncodeParam(image);
        params.setQuality(1f, true);
        jpegEncoder.encode(image, params);
        }
        catch (IOException e)
        {
        // e.printStackTrace();
        }
        }
        }

        class ReaderThread implements Runnable
        {
        Thread thread;
        PipedInputStream in;

        public ReaderThread(PipedInputStream pistream)
        {
        in = pistream;
        }

        public void start()
        {
        if (thread == null)
        {
        thread = new Thread(this, "ReaderThread");
        thread.start();
        }
        }

        public void run()
        {
        byte[] buffer = new byte[128];

        try
        {
        // Read 1 byte and close the connection.
        // Watch the VM go *bang*
        in.read();
        in.close();
        }
        catch (IOException e)
        {
        // e.printStackTrace();
        }
        }
        }

        public class Test
        {
        public static void main(String[] args)
        {
        while(true)
        {
        try
        {
        PipedInputStream pistream = new PipedInputStream();
        PipedOutputStream postream = new PipedOutputStream(pistream);

        WriterThread writer = new WriterThread(postream);
        ReaderThread reader = new ReaderThread(pistream);

        writer.start();
        reader.start();
        } catch (IOException e)
        {
        // e.printStackTrace();
        }

        System.out.print(".");

        try
        {
        Thread.currentThread().sleep(500);
        } catch (Exception e)
        {
        }
        }
        }
        }
        (Review ID: 131636)
        ======================================================================

        Verified with merlin-rc1 build. Not fixed.
        The exception still remain not only on win2000( , it also happens on solaris 2.8

        ###@###.### 2001-12-19

        Acutally, the exceptions were caused by JPEGMultithread bug 4502892. Thanks for Chris to point it out. Verify as Fixed.

        ###@###.### 2001-12-19

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  campbell Christopher Campbell (Inactive)
                  Reporter:
                  gmanwanisunw Girish Manwani (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: