ASF Bugzilla – Attachment 21368 Details for
Bug 30094
Performance enhancements using java.nio & lazy calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
[faulty] java.nio changes against Ant 1.7.0, in unified diff format
ant.resourceutils.nio.diff (text/plain), 2.83 KB, created by
Robin Verduijn
on 2008-01-09 11:54:23 UTC
(
hide
)
Description:
[faulty] java.nio changes against Ant 1.7.0, in unified diff format
Filename:
MIME Type:
Creator:
Robin Verduijn
Created:
2008-01-09 11:54:23 UTC
Size:
2.83 KB
patch
obsolete
>==== apache-ant-1.7.0/src/main/org/apache/tools/ant/util/ResourceUtils.java#1 - apache-ant-1.7.0\src\main\org\apache\tools\ant\util\ResourceUtils.java ==== >@@ -31,6 +31,12 @@ > import java.util.Vector; > import java.util.Iterator; > >+// for NIO support: >+import java.io.FileInputStream; >+import java.io.FileOutputStream; >+import java.nio.channels.FileChannel; >+import org.apache.tools.ant.types.resources.FileResource; >+ > import org.apache.tools.ant.Project; > import org.apache.tools.ant.ProjectComponent; > import org.apache.tools.ant.filters.util.ChainReaderHelper; >@@ -77,6 +83,9 @@ > > private static final ResourceSelector NOT_EXISTS = new Not(new Exists()); > >+ // for NIO support: >+ private static final int TRANSFER_SIZE = 65535; >+ > /** > * Tells which source files should be reprocessed based on the > * last modification date of target files. >@@ -372,6 +381,40 @@ > FileUtils.close(in); > } > } else { >+ if( source instanceof FileResource && dest instanceof FileResource ) { >+ File sourceFile = ((FileResource) source).getFile(); >+ File destFile = ((FileResource) dest).getFile(); >+ >+ FileInputStream in = null; >+ FileOutputStream out = null; >+ FileChannel srcChannel = null; >+ FileChannel destChannel = null; >+ >+ try { >+ File parent = destFile.getParentFile(); >+ if (parent != null && !parent.exists()) { >+ parent.mkdirs(); >+ } >+ >+ in = new FileInputStream(sourceFile); >+ out = new FileOutputStream(destFile); >+ >+ srcChannel = in.getChannel(); >+ destChannel = out.getChannel(); >+ >+ long position = 0; >+ long count = srcChannel.size(); >+ while( position < count ) { >+ position += srcChannel.transferTo(position, TRANSFER_SIZE, destChannel); >+ } >+ } finally { >+ if (srcChannel != null) srcChannel.close(); >+ if (destChannel != null) destChannel.close(); >+ FileUtils.close(out); >+ FileUtils.close(in); >+ } >+ } else { >+ System.out.println("Not ennabling NIO file copies. Boo!"); > InputStream in = null; > OutputStream out = null; > try { >@@ -389,6 +432,7 @@ > FileUtils.close(in); > } > } >+ } > if (preserveLastModified && dest instanceof Touchable) { > setLastModified((Touchable) dest, source.getLastModified()); > }
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 30094
:
12110
|
17385
|
17386
|
17388
|
17389
|
21368
|
21369