Menu

#1317 OBL_UNSATISFIED_OBLIGATION fails when extending FileInputStream

3.x
closed-fixed
None
5
2015-02-25
2014-10-29
No

Having the following falsly detects that the stream may not be closed. This inputstream should be closed wherever this inputstream is created instead of in this class.

public class TempFileInputStream extends FileInputStream {

private final File tmpFile;

/**

 * Constructor.
 * @param file een tempfile die verwijderd kan worden bij het sluiten van de stream.
 * @throws FileNotFoundException 
 */
public TempFileInputStream(File file) throws FileNotFoundException {
    super(file);
    this.tmpFile = file;
}

@Override
public void close() throws IOException {
    try {
        super.close();
    } finally {
       tmpFile.delete();
    }
}

}

Discussion

  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09
    • status: open --> open-accepted
     
  • William Pugh

    William Pugh - 2015-02-25
    • status: open-accepted --> closed-fixed
    • assigned_to: William Pugh
     
  • William Pugh

    William Pugh - 2015-02-25

    Fixed, thank you.

     

Log in to post a comment.

MongoDB Logo MongoDB