Revision 8304
Added by Matt Jones over 10 years ago
Eml2oai_dc.java | ||
---|---|---|
21 | 21 |
import javax.xml.transform.stream.StreamResult; |
22 | 22 |
import javax.xml.transform.stream.StreamSource; |
23 | 23 |
|
24 |
import org.apache.commons.io.IOUtils; |
|
25 |
|
|
24 | 26 |
import ORG.oclc.oai.server.crosswalk.Crosswalk; |
25 | 27 |
import ORG.oclc.oai.server.verb.CannotDisseminateFormatException; |
26 | 28 |
import ORG.oclc.oai.server.verb.OAIInternalServerError; |
... | ... | |
69 | 71 |
String xsltPath200 = dirPath + "/" + XSLT_NAME_200; |
70 | 72 |
String xsltPath201 = dirPath + "/" + XSLT_NAME_201; |
71 | 73 |
String xsltPath210 = dirPath + "/" + XSLT_NAME_210; |
74 |
FileInputStream fileInputStream200 = null; |
|
75 |
FileInputStream fileInputStream201 = null; |
|
76 |
FileInputStream fileInputStream210 = null; |
|
72 | 77 |
|
73 | 78 |
try { |
74 | 79 |
TransformerFactory tFactory200 = TransformerFactory.newInstance(); |
75 |
FileInputStream fileInputStream200 = new FileInputStream(xsltPath200);
|
|
80 |
fileInputStream200 = new FileInputStream(xsltPath200); |
|
76 | 81 |
StreamSource xslSource200 = new StreamSource(fileInputStream200); |
77 | 82 |
this.transformer200 = tFactory200.newTransformer(xslSource200); |
78 |
|
|
83 |
fileInputStream200.close(); |
|
84 |
|
|
79 | 85 |
TransformerFactory tFactory201 = TransformerFactory.newInstance(); |
80 |
FileInputStream fileInputStream201 = new FileInputStream(xsltPath201);
|
|
86 |
fileInputStream201 = new FileInputStream(xsltPath201); |
|
81 | 87 |
StreamSource xslSource201 = new StreamSource(fileInputStream201); |
82 | 88 |
this.transformer201 = tFactory201.newTransformer(xslSource201); |
83 |
|
|
89 |
fileInputStream201.close(); |
|
90 |
|
|
84 | 91 |
TransformerFactory tFactory210 = TransformerFactory.newInstance(); |
85 |
FileInputStream fileInputStream210 = new FileInputStream(xsltPath210);
|
|
92 |
fileInputStream210 = new FileInputStream(xsltPath210); |
|
86 | 93 |
StreamSource xslSource210 = new StreamSource(fileInputStream210); |
87 | 94 |
this.transformer210 = tFactory210.newTransformer(xslSource210); |
95 |
fileInputStream210.close(); |
|
88 | 96 |
|
89 | 97 |
} |
90 | 98 |
catch (Exception e) { |
91 | 99 |
e.printStackTrace(); |
92 | 100 |
throw new OAIInternalServerError(e.getMessage()); |
101 |
} finally { |
|
102 |
IOUtils.closeQuietly(fileInputStream200); |
|
103 |
IOUtils.closeQuietly(fileInputStream201); |
|
104 |
IOUtils.closeQuietly(fileInputStream210); |
|
93 | 105 |
} |
94 | 106 |
} |
95 | 107 |
|
Also available in: Unified diff
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.