Author: schor
Date: Wed Feb  8 23:00:40 2012
New Revision: 1242167

URL: http://svn.apache.org/viewvc?rev=1242167&view=rev
Log:
[UIMA-2369] temporary patch - makes mac work, plus rollback to 3-SNAPSHOT

Modified:
    uima/build/trunk/uima-build-helper-maven-plugin/pom.xml
    
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/CopyFromApacheDist.java

Modified: uima/build/trunk/uima-build-helper-maven-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/pom.xml?rev=1242167&r1=1242166&r2=1242167&view=diff
==============================================================================
--- uima/build/trunk/uima-build-helper-maven-plugin/pom.xml (original)
+++ uima/build/trunk/uima-build-helper-maven-plugin/pom.xml Wed Feb  8 23:00:40 
2012
@@ -28,7 +28,7 @@
   </parent>
   
   <artifactId>uima-build-helper-maven-plugin</artifactId>
-  <version>4-SNAPSHOT</version>
+  <version>3-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <inceptionYear>2010</inceptionYear>

Modified: 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/CopyFromApacheDist.java
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/CopyFromApacheDist.java?rev=1242167&r1=1242166&r2=1242167&view=diff
==============================================================================
--- 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/CopyFromApacheDist.java
 (original)
+++ 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/CopyFromApacheDist.java
 Wed Feb  8 23:00:40 2012
@@ -130,6 +130,7 @@ public class CopyFromApacheDist extends 
 
     FileOutputStream os = null;
     try {
+      targetFile.getParentFile().mkdirs();
       os = new FileOutputStream(targetFile);
     } catch (FileNotFoundException e) {
       throw new MojoExecutionException("While creating local file in location 
" + targetFile.getAbsolutePath(), e);    
@@ -138,21 +139,33 @@ public class CopyFromApacheDist extends 
     System.out.format("copy-from-apache-dist file %s to %s%n", remoteLocation, 
targetInLocalFileSystem);
     
     byte[] buf = new byte[1024*1024];  // buffer size
-    while(true) {
-      int bytesRead;
-      try {
-        bytesRead = is.read(buf);
-      } catch (IOException e) {
-        throw new MojoExecutionException("While reading remote file in 
location " + remoteLocation, e);    
+    // still getting partial transfers.  
+    // trying: when receive a negative for bytes read, retry 3 times with a .5 
second delay
+    for (int retries = 0; retries < 3; retries ++) {
+      while(true) {
+        int bytesRead;
+        try {
+          bytesRead = is.read(buf);
+        } catch (IOException e) {
+          throw new MojoExecutionException("While reading remote file in 
location " + remoteLocation, e);    
+        }
+        if (bytesRead < 0) {
+          try {
+            Thread.sleep(500); //wait 1/2 a second
+          } catch (InterruptedException e) {
+          }  
+          break;
+        }
+        if (retries > 0) {
+          System.out.format("retrying read successful after %d retries%n", 
retries);
+        }
+        retries = 0; // reset the retry counter... 
+        try {
+          os.write(buf, 0, bytesRead);
+        } catch (IOException e) {
+          throw new MojoExecutionException("While writing target file in 
location " + targetFile.getAbsolutePath(), e);    
+       }
       }
-      if (bytesRead < 0) {
-        break;
-      }
-      try {
-        os.write(buf, 0, bytesRead);
-      } catch (IOException e) {
-        throw new MojoExecutionException("While writing target file in 
location " + targetFile.getAbsolutePath(), e);    
-     }
     }
     try {
       os.close();


Reply via email to