[
https://issues.apache.org/activemq/browse/SM-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet resolved SM-1012.
---------------------------------
Resolution: Fixed
Fix Version/s: 3.2
3.1.2
Assignee: Guillaume Nodet
URL: http://svn.apache.org/viewvc?view=rev&rev=561009
> Possible resource leak in FilePoller
> ------------------------------------
>
> Key: SM-1012
> URL: https://issues.apache.org/activemq/browse/SM-1012
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-file
> Affects Versions: 3.1.1
> Environment: Windows XP, JDK 5.0
> Reporter: Artur Karazniewicz
> Assignee: Guillaume Nodet
> Priority: Minor
> Fix For: 3.1.2, 3.2
>
>
> In the org.apache.servicemix.components.file.FilePoller#processFile(File) it
> is possible that allocated file would leak. Now, it goes like:
> protected void processFile(File aFile) throws Exception {
> String name = aFile.getCanonicalPath();
> InputStream in = new BufferedInputStream(new FileInputStream(aFile));
> InOnly exchange = getExchangeFactory().createInOnlyExchange();
> NormalizedMessage message = exchange.createMessage();
> exchange.setInMessage(message);
> marshaler.readMessage(exchange, message, in, name);
> getDeliveryChannel().sendSync(exchange);
> in.close();
> }
> But, we should properly clean-up in the case of exception thrown before
> in.close(). Thus, should be:
> protected void processFile(File aFile) throws Exception {
> InputStream in = null;
> try {
> String name = aFile.getCanonicalPath();
> in = new BufferedInputStream(new
> FileInputStream(aFile));
> InOnly exchange =
> getExchangeFactory().createInOnlyExchange();
> NormalizedMessage message = exchange.createMessage();
> exchange.setInMessage(message);
> marshaler.readMessage(exchange, message, in, name);
> getDeliveryChannel().sendSync(exchange);
> }
> finally {
> if (in != null) {
> in.close();
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.