diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF index 57ec00d349..4b8655b932 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.p2.discovery.compatibility;singleton:=true -Bundle-Version: 1.3.300.qualifier +Bundle-Version: 1.3.400.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/CacheManager.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/CacheManager.java index c7ddd6ab69..81267a21fa 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/CacheManager.java +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/CacheManager.java @@ -198,8 +198,8 @@ protected void updateCache(File cacheFile, URI remoteFile, long lastModifiedRemo tempFile.createNewFile(); + IStatus result = null; try (StatefulStream stream = new StatefulStream(new FileOutputStream(tempFile))) { - IStatus result = null; try { submonitor.setWorkRemaining(1000); result = transport.download(remoteFile, stream, submonitor.newChild(1000)); @@ -213,21 +213,21 @@ protected void updateCache(File cacheFile, URI remoteFile, long lastModifiedRemo if (result == null || !result.isOK()) safeDelete(tempFile); } - if (result.isOK()) { - if (cacheFile.exists()) - safeDelete(cacheFile); - if (tempFile.renameTo(cacheFile)) - return; - result = new Status(IStatus.ERROR, Activator.ID, - NLS.bind(Messages.CacheManage_ErrorRenamingCache, new Object[] { remoteFile.toString(), - tempFile.getAbsolutePath(), cacheFile.getAbsolutePath() })); - } - - if (result.getSeverity() == IStatus.CANCEL || submonitor.isCanceled()) - throw new OperationCanceledException(); - throw new ProvisionException(result); } catch (FileNotFoundException e) { throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e)); } + + if (result != null && result.isOK()) { + if (cacheFile.exists()) + safeDelete(cacheFile); + if (tempFile.renameTo(cacheFile)) + return; + result = new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.CacheManage_ErrorRenamingCache, + new Object[] { remoteFile.toString(), tempFile.getAbsolutePath(), cacheFile.getAbsolutePath() })); + } + + if (result != null && result.getSeverity() == IStatus.CANCEL || submonitor.isCanceled()) + throw new OperationCanceledException(); + throw new ProvisionException(result); } }