Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 39119 Details for
Bug 137336
Request for update.core to avoid nio transferTo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
updated patch to test for NIO classes
137336-3.patch (text/plain), 3.87 KB, created by
Phil Loats
on 2006-04-20 18:29:26 EDT
(
hide
)
Description:
updated patch to test for NIO classes
Filename:
MIME Type:
Creator:
Phil Loats
Created:
2006-04-20 18:29:26 EDT
Size:
3.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.update.core >Index: src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 JarDeltaInstallHandler.java >--- src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 15 Nov 2005 06:01:07 -0000 1.1 >+++ src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 20 Apr 2006 22:17:16 -0000 >@@ -18,7 +18,6 @@ > import java.io.InputStream; > import java.net.URI; > import java.net.URISyntaxException; >-import java.nio.channels.FileChannel; > import java.util.Date; > import java.util.Enumeration; > import java.util.jar.JarFile; >@@ -90,15 +89,46 @@ > newJarFile.delete(); > > newJarFile.createNewFile(); >- >- FileChannel in = new FileInputStream(tempFile).getChannel(); >- FileChannel out = new FileOutputStream(newJarFile).getChannel(); >- in.transferTo( 0, in.size(), out); >- >- in.close(); >- out.close(); >+ >+ copyFile(tempFile, newJarFile); > } > >+ static boolean useNioCopy = true; >+ public static void copyFile(File src, File dst) throws IOException { >+ if (useNioCopy) { >+ try { >+ NioHelper.copyFile(src, dst); >+ return; >+ } catch (IOException e) { >+ throw e; >+ } catch (NoSuchMethodError e1) { >+ // fall through >+ } catch (NoClassDefFoundError e2) { >+ // fall through >+ } catch (Exception e3) { >+ // fall through >+ } >+ useNioCopy = false; >+ } >+ >+ FileInputStream in=null; >+ FileOutputStream out=null; >+ try { >+ in = new FileInputStream(src); >+ out = new FileOutputStream(dst); >+ byte[] buffer = new byte[4096]; >+ int len; >+ while ((len=in.read(buffer)) != -1) { >+ out.write(buffer, 0, len); >+ } >+ } finally { >+ if (in != null) >+ in.close(); >+ if (out != null) >+ out.close(); >+ } >+ } >+ > public static void addToJar(JarOutputStream jos, JarFile jf) throws IOException { > Enumeration e = jf.entries(); > >Index: src/org/eclipse/update/internal/core/NioHelper.java >=================================================================== >RCS file: src/org/eclipse/update/internal/core/NioHelper.java >diff -N src/org/eclipse/update/internal/core/NioHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/update/internal/core/NioHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.update.internal.core; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.nio.channels.FileChannel; >+ >+ >+public class NioHelper { >+ // This method must be in a seperate class file otherwise a NIO class not found error >+ // will be thrown loading the calling class. We put it in it's own class so the >+ // caller can catch the error/exception. >+ static void copyFile(File src, File dst) throws IOException { >+ FileChannel in = null; >+ FileChannel out = null; >+ >+ try { >+ in = new FileInputStream(src).getChannel(); >+ out = new FileOutputStream(dst).getChannel(); >+ in.transferTo( 0, in.size(), out); >+ } finally { >+ if (in != null) >+ in.close(); >+ if (out != null) >+ out.close(); >+ } >+ } >+ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 137336
:
38839
|
39116
|
39119
|
39123