You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2015/05/26 07:55:42 UTC

jclouds git commit: JCLOUDS-912: Implement RandomInputStream.close

Repository: jclouds
Updated Branches:
  refs/heads/master 6fa59ca22 -> ff1f2c01e


JCLOUDS-912: Implement RandomInputStream.close

Prevent reading closed RandomInputStream.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/ff1f2c01
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/ff1f2c01
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/ff1f2c01

Branch: refs/heads/master
Commit: ff1f2c01ef21fe4f0724d5e8b0b76d19376a1150
Parents: 6fa59ca
Author: Andrew Gaul <ga...@apache.org>
Authored: Mon May 25 21:53:52 2015 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Mon May 25 22:26:09 2015 -0700

----------------------------------------------------------------------
 core/src/test/java/org/jclouds/utils/TestUtils.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/ff1f2c01/core/src/test/java/org/jclouds/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/utils/TestUtils.java b/core/src/test/java/org/jclouds/utils/TestUtils.java
index ae3fb8e..90d7310 100644
--- a/core/src/test/java/org/jclouds/utils/TestUtils.java
+++ b/core/src/test/java/org/jclouds/utils/TestUtils.java
@@ -59,13 +59,17 @@ public class TestUtils {
 
     private static class RandomInputStream extends InputStream {
         private final Random random;
+        private boolean closed = false;
 
         RandomInputStream(long seed) {
            this.random = new Random(seed);
         }
 
         @Override
-        public synchronized int read() {
+        public synchronized int read() throws IOException {
+            if (closed) {
+                throw new IOException("Stream already closed");
+            }
             return (byte) random.nextInt();
         }
 
@@ -81,5 +85,11 @@ public class TestUtils {
             }
             return len;
         }
+
+        @Override
+        public void close() throws IOException {
+            super.close();
+            closed = true;
+        }
     }
 }