diff options
| author | Sergey Prigogin | 2015-07-16 02:31:31 +0000 |
|---|---|---|
| committer | Sergey Prigogin | 2015-07-24 21:51:31 +0000 |
| commit | 7ae8635247606c7dbd44aae8cbdabf845dc90286 (patch) | |
| tree | 98ab265717531a8bd9a9fbbd2d7a7a24e4cb447c | |
| parent | 796a5787a078d33f068f0fa8622fcf58e163827d (diff) | |
| download | eclipse.platform.resources-7ae8635247606c7dbd44aae8cbdabf845dc90286.tar.gz eclipse.platform.resources-7ae8635247606c7dbd44aae8cbdabf845dc90286.tar.xz eclipse.platform.resources-7ae8635247606c7dbd44aae8cbdabf845dc90286.zip | |
Bug 260366 - [EFS] Blocking file transfers in EFS
Change-Id: I2eb65a2392e89208ab1d0cb43ff1d5a7a061815b
| -rw-r--r-- | bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java index ae235bc2b..8730e6616 100644 --- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java +++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java @@ -35,13 +35,6 @@ public class FileUtil { static final boolean MACOSX = Constants.OS_MACOSX.equals(getOS()); /** - * Singleton buffer created to prevent buffer creations in the - * transferStreams method. Used as an optimization, based on the assumption - * that multiple writes won't happen in a given instance of FileStore. - */ - private static final byte[] buffer = new byte[8192]; - - /** * Converts a ResourceAttributes object into an IFileInfo object. * @param attributes The resource attributes * @return The file info @@ -406,33 +399,27 @@ public class FileUtil { public static final void transferStreams(InputStream source, OutputStream destination, String path, IProgressMonitor monitor) throws CoreException { monitor = Policy.monitorFor(monitor); try { - /* - * Note: although synchronizing on the buffer is thread-safe, - * it may result in slower performance in the future if we want - * to allow concurrent writes. - */ - synchronized (buffer) { - while (true) { - int bytesRead = -1; - try { - bytesRead = source.read(buffer); - } catch (IOException e) { - String msg = NLS.bind(Messages.localstore_failedReadDuringWrite, path); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, new Path(path), msg, e); - } - try { - if (bytesRead == -1) { - // Bug 332543 - ensure we don't ignore failures on close() - destination.close(); - break; - } - destination.write(buffer, 0, bytesRead); - } catch (IOException e) { - String msg = NLS.bind(Messages.localstore_couldNotWrite, path); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, new Path(path), msg, e); + byte[] buffer = new byte[8192]; + while (true) { + int bytesRead = -1; + try { + bytesRead = source.read(buffer); + } catch (IOException e) { + String msg = NLS.bind(Messages.localstore_failedReadDuringWrite, path); + throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, new Path(path), msg, e); + } + try { + if (bytesRead == -1) { + // Bug 332543 - ensure we don't ignore failures on close() + destination.close(); + break; } - monitor.worked(1); + destination.write(buffer, 0, bytesRead); + } catch (IOException e) { + String msg = NLS.bind(Messages.localstore_couldNotWrite, path); + throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, new Path(path), msg, e); } + monitor.worked(1); } } finally { safeClose(source); |
