Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2011-08-19 13:15:52 +0400
committerjfrijters <jfrijters>2011-08-19 13:15:52 +0400
commit7737b9b19638620cf9965fc8b8e329d398ebc011 (patch)
tree67655c9c18249fed75759c695163bdb9e5b548ef /openjdk/sun/nio/ch
parent2462429eb70e7d88d13a6346dd7dfd66997854a4 (diff)
Fix to make sure that FileChannel.transferFrom() throws a NonReadableChannelException when the source is a write-only FileChannel.
Diffstat (limited to 'openjdk/sun/nio/ch')
-rw-r--r--openjdk/sun/nio/ch/FileChannelImpl.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/openjdk/sun/nio/ch/FileChannelImpl.java b/openjdk/sun/nio/ch/FileChannelImpl.java
index 6a27b012..86049d69 100644
--- a/openjdk/sun/nio/ch/FileChannelImpl.java
+++ b/openjdk/sun/nio/ch/FileChannelImpl.java
@@ -435,6 +435,15 @@ public class FileChannelImpl
return transferToArbitraryChannel(position, icount, target);
}
+ private long transferFromFileChannel(FileChannelImpl src,
+ long position, long count)
+ throws IOException
+ {
+ if (!src.readable)
+ throw new NonReadableChannelException();
+ return transferFromArbitraryChannel(src, position, count);
+ }
+
private static final int TRANSFER_SIZE = 8192;
private long transferFromArbitraryChannel(ReadableByteChannel src,
@@ -483,6 +492,9 @@ public class FileChannelImpl
throw new IllegalArgumentException();
if (position > size())
return 0;
+ if (src instanceof FileChannelImpl)
+ return transferFromFileChannel((FileChannelImpl)src,
+ position, count);
return transferFromArbitraryChannel(src, position, count);
}