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

Null Pointer Exception in PaletteBuilder

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      $ java -version
      java version "1.6.0_05"
      Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If a buffered image is created and then written to a GIF WITHOUT drawing
      anything into it, a null pointer exception is thrown in PalletteBuilder.

      This does not occur in Java 1.7 build 24.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac -Xlint:all test.java
      java test 1

      Note the argument.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No output.
      ACTUAL -
      Error traceback for NullPointerException.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java test 1
      Exception in thread "main" java.lang.NullPointerException
              at com.sun.imageio.plugins.common.PaletteBuilder.findPaletteEntry(PaletteBuilder.java:310)
              at com.sun.imageio.plugins.common.PaletteBuilder.getIndexColorModel(PaletteBuilder.java:296)
              at com.sun.imageio.plugins.common.PaletteBuilder.getIndexedImage(PaletteBuilder.java:145)
              at com.sun.imageio.plugins.common.PaletteBuilder.createIndexedImage(PaletteBuilder.java:77)
              at com.sun.imageio.plugins.gif.GIFImageWriter.write(GIFImageWriter.java:564)
              at com.sun.imageio.plugins.gif.GIFImageWriter.write(GIFImageWriter.java:492)
              at javax.imageio.ImageWriter.write(ImageWriter.java:598)
              at javax.imageio.ImageIO.write(ImageIO.java:1479)
              at javax.imageio.ImageIO.write(ImageIO.java:1521)
              at test.main(test.java:25)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Graphics2D;
      import java.awt.image.BufferedImage;
      import java.io.File;
      import java.io.IOException;
      import javax.imageio.ImageIO;


      public class test extends Object
      {
          public static void main(final String[] args) throws Exception
          {
              final BufferedImage bufferedImage =
                                      new BufferedImage(1000,
                                                        1000,
                                                        BufferedImage.TYPE_INT_ARGB);
              if (args.length < 1)
              {
                  final Graphics2D graphics = bufferedImage.createGraphics();

                  final BufferedImage icon = ImageIO.read(new File("icon.gif"));

                  graphics.drawImage(icon, 100, 100, null);
              }

              if (! ImageIO.write(bufferedImage, "GIF", new File("output.gif")))
              {
                  throw new IOException();
              }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Java 1.7.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bae Andrew Brygin
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: