Menu

#79 NPE in File.close()

0.1.2.1
open
nobody
file (1)
5
2015-06-22
2015-06-22
maol
No

Build pdfclown.jar on 22 june 2015 (clown-code-223-trunk).

Got a NPE when closing the file object created from an InputStream:

java.lang.NullPointerException
at java.io.File.<init>(File.java:251)
at org.pdfclown.files.File.close(File.java:410)

Calling code:

public static List<java.awt.Rectangle> searchAndHighlightText(InputStream pdfInputStream, OutputStream pdfOutputStream, String textRegex) {

    org.pdfclown.files.File file = null;

    try {

        file = new org.pdfclown.files.File(pdfInputStream);
                    ...
    } 
    finally {
        try {
            if(file != null) file.close();
        } catch (IOException e) {
            LOGGER.warn("Error closing PDF Clown file: " + e.getMessage());
        }
    }

Discussion


Log in to post a comment.