Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lindberg2009-04-15 02:26:51 +0000
committerHenrik Lindberg2009-04-15 02:26:51 +0000
commit6fe5b52528f3d28fe1cba903314b3e94e0f643d6 (patch)
tree6e87a112204a45dff2e196570fe3676f900a411d /bundles/org.eclipse.equinox.p2.updatesite
parent839cd1c83058d1f81c8f2b3eee98000bed4c85f0 (diff)
downloadrt.equinox.p2-6fe5b52528f3d28fe1cba903314b3e94e0f643d6.tar.gz
rt.equinox.p2-6fe5b52528f3d28fe1cba903314b3e94e0f643d6.tar.xz
rt.equinox.p2-6fe5b52528f3d28fe1cba903314b3e94e0f643d6.zip
Bug 271181 [transport] UpdateSite parse methods can leave a stream open.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.updatesite')
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/UpdateSite.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/UpdateSite.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/UpdateSite.java
index 4ca1be6bc..658ae575b 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/UpdateSite.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/UpdateSite.java
@@ -138,11 +138,14 @@ public class UpdateSite {
} catch (IOException e) {
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.INTERNAL_ERROR, "Can not create tempfile for site.xml", e)); //$NON-NLS-1$
}
- transferResult = getTransport().download(actualLocation, destination, submonitor.newChild(999));
try {
- destination.close();
- } catch (IOException e) {
- throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.INTERNAL_ERROR, "Failing to close tempfile for site.xml", e)); //$NON-NLS-1$
+ transferResult = getTransport().download(actualLocation, destination, submonitor.newChild(999));
+ } finally {
+ try {
+ destination.close();
+ } catch (IOException e) {
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.INTERNAL_ERROR, "Failing to close tempfile for site.xml", e)); //$NON-NLS-1$
+ }
}
}
if (monitor.isCanceled())
@@ -197,12 +200,15 @@ public class UpdateSite {
if (monitor.isCanceled())
throw new OperationCanceledException();
OutputStream destination = new BufferedOutputStream(new FileOutputStream(featureFile));
- transferResult = getTransport().download(featureURI, destination, monitor);
try {
- destination.close();
- } catch (IOException e) {
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.ErrorReadingFeature, featureURI), e));
- return null;
+ transferResult = getTransport().download(featureURI, destination, monitor);
+ } finally {
+ try {
+ destination.close();
+ } catch (IOException e) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.ErrorReadingFeature, featureURI), e));
+ return null;
+ }
}
if (transferResult.isOK())
break;
@@ -407,12 +413,16 @@ public class UpdateSite {
} else {
digestFile = File.createTempFile("digest", ".zip"); //$NON-NLS-1$ //$NON-NLS-2$
BufferedOutputStream destination = new BufferedOutputStream(new FileOutputStream(digestFile));
- IStatus result = getTransport().download(digestURI, destination, monitor);
+ IStatus result = null;
try {
- destination.close();
- } catch (IOException e) {
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.ErrorReadingDigest, location), e));
- return null;
+ result = getTransport().download(digestURI, destination, monitor);
+ } finally {
+ try {
+ destination.close();
+ } catch (IOException e) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.ErrorReadingFeature, location), e));
+ return null;
+ }
}
if (result.getSeverity() == IStatus.CANCEL || monitor.isCanceled())
throw new OperationCanceledException();

Back to the top