[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#556978: sun-java6-bin: javax.imageio.ImageIO.write prints stack trace if file un-writable.

Package: sun-java6-bin
Version: 6-16-1
Severity: normal

The following program prints on stderr:

java.io.FileNotFoundException: /test.png (Permission denied)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
        at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:53)
        at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:37)
        at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:393)
        at javax.imageio.ImageIO.write(ImageIO.java:1514)
        at Fail.main(Fail.java:10)
--- BELOW HERE ---
        at javax.imageio.ImageIO.write(ImageIO.java:1523)
        at Fail.main(Fail.java:10)

The line "--- BELOW HERE ---" should be the first output.

import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.*;

public final class Fail {
  public static void main(String[] args) throws java.io.IOException {
    try {
      File out = new File("/test.png");
      BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
      javax.imageio.ImageIO.write(image, "PNG", out);
    } catch (Throwable e) {
      System.err.println("--- BELOW HERE ---");

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.31-honey2 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages sun-java6-bin depends on:
ii  debconf [debconf-2.0]         1.5.28     Debian configuration management sy
ii  libc6                         2.10.1-7   GNU C Library: Shared libraries
ii  sun-java6-jre                 6-16-1     Sun Java(TM) Runtime Environment (
ii  unixodbc                      2.2.11-21  ODBC tools libraries

Versions of packages sun-java6-bin recommends:
ii  libasound2                    1.0.21a-1  shared library for ALSA applicatio
ii  libnss-mdns                   0.10-3.1   NSS module for Multicast DNS name 
ii  libx11-6                      2:1.2.2-1  X11 client-side library
ii  libxext6                      2:1.0.4-1  X11 miscellaneous extension librar
ii  libxi6                        2:1.2.1-2  X11 Input extension library
ii  libxtst6                      2:1.0.3-1  X11 Testing -- Resource extension 

Versions of packages sun-java6-bin suggests:
pn  binfmt-support                <none>     (no description available)

-- debconf information excluded

Reply to: