Project

General

Profile

« Previous | Next » 

Revision 8304

Added by Matt Jones over 10 years ago

Reviewed code for all uses of FileInputStream, checking to see if the method should be closing the stream, and if so, closing it in the method as well as in the finally clause to ensure we don't leak file descriptors.

View differences:

MetacatHandler.java
65 65
import javax.servlet.http.HttpServletResponse;
66 66
import javax.servlet.http.HttpSession;
67 67

  
68
import org.apache.commons.io.IOUtils;
68 69
import org.apache.commons.io.input.XmlStreamReader;
69 70
import org.apache.log4j.Logger;
70 71
import org.dataone.service.types.v1.Identifier;
......
1279 1280
                        out.write(buf, 0, b);
1280 1281
                        b = fin.read(buf);
1281 1282
                    }
1283
                    fin.close();
1282 1284
                } finally {
1283
                    if (fin != null) fin.close();
1285
                    IOUtils.closeQuietly(fin);
1284 1286
                }
1285 1287
                
1286 1288
            } else {
......
1549 1551
                            zout.write(buf, 0, b);
1550 1552
                            b = fin.read(buf);
1551 1553
                        }
1554
                        fin.close();
1552 1555
                    } finally {
1553
                        if (fin != null) fin.close();
1556
                        IOUtils.closeQuietly(fin);
1554 1557
                    }
1555 1558
                    zout.closeEntry();
1556 1559
                    

Also available in: Unified diff