Author: jawi
Date: Thu Sep 19 14:09:47 2013
New Revision: 1524744
URL: http://svn.apache.org/r1524744
Log:
Added some additional logging to trace the failing test on Solaris machines.
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadCallableImpl.java
ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandleImplTest.java
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadCallableImpl.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadCallableImpl.java?rev=1524744&r1=1524743&r2=1524744&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadCallableImpl.java
(original)
+++
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadCallableImpl.java
Thu Sep 19 14:09:47 2013
@@ -23,6 +23,7 @@ import static org.apache.ace.agent.impl.
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.util.concurrent.Callable;
@@ -63,10 +64,14 @@ final class DownloadCallableImpl impleme
byte buffer[] = new byte[READBUFFER_SIZE];
long bytesRead = targetLength, totalBytes = -1L;
- int read;
+ int read = 0;
try {
- while (!Thread.currentThread().isInterrupted() && (read =
is.read(buffer)) >= 0) {
+ while (!Thread.currentThread().isInterrupted() && (read >= 0))
{
+ read = is.read(buffer);
+ if (read < 0) {
+ break; // EOF...
+ }
os.write(buffer, 0, read);
// update local administration...
bytesRead += read;
@@ -77,6 +82,10 @@ final class DownloadCallableImpl impleme
}
}
}
+ catch (InterruptedIOException exception) {
+ // restore interrupted flag...
+ Thread.currentThread().interrupt();
+ }
finally {
// Ensure that buffers are flushed in our output stream...
os.flush();
Modified:
ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandleImplTest.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandleImplTest.java?rev=1524744&r1=1524743&r2=1524744&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandleImplTest.java
(original)
+++
ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandleImplTest.java
Thu Sep 19 14:09:47 2013
@@ -188,6 +188,7 @@ public class DownloadHandleImplTest exte
future = handle.start(new DownloadProgressListener() {
@Override
public void progress(long bytesRead, long totalBytes) {
+ System.out.printf("Downloaded %d from %d bytes, interrupting
download...%n", bytesRead, totalBytes);
Thread.currentThread().interrupt();
}
});
@@ -206,6 +207,7 @@ public class DownloadHandleImplTest exte
future = handle2.start(new DownloadProgressListener() {
@Override
public void progress(long bytesRead, long totalBytes) {
+ System.out.printf("Downloaded %d from %d bytes, stopping
download...%n", bytesRead, totalBytes);
handle2.stop();
}
});
@@ -214,7 +216,9 @@ public class DownloadHandleImplTest exte
long secondFileLength = file.length();
- assertTrue(secondFileLength > firstFileLength, "Nothing downloaded yet
for " + file.getName() + "?");
+ System.out.printf("First size: %d, second size: %d; total = %d.%n",
firstFileLength, secondFileLength, m_contentLength);
+
+ assertTrue(secondFileLength > firstFileLength, "Nothing extra
downloaded for " + file.getName() + "?");
assertTrue(secondFileLength < m_contentLength, "Everything downloaded
for " + file.getName() + "?");
DownloadHandle handle3 = downloadHandler.getHandle(m_testContentURL);