diff --git a/CHANGES.txt b/CHANGES.txt index db306eae65..b2abd10043 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -20,15 +20,17 @@ 2.2.0-rc3 + * Don't wrap byte arrays in SequentialWriter (CASSANDRA-9797) + * sum() and avg() functions missing for smallint and tinyint types (CASSANDRA-9671) * Revert CASSANDRA-9542 (allow native functions in UDA) (CASSANDRA-9771) Merged from 2.1: * Fix broken logging for "empty" flushes in Memtable (CASSANDRA-9837) - * Complete CASSANDRA-8448 fix (CASSANDRA-9519) * Handle corrupt files on startup (CASSANDRA-9686) * Fix clientutil jar and tests (CASSANDRA-9760) * (cqlsh) Allow the SSL protocol version to be specified through the config file or environment variables (CASSANDRA-9544) Merged from 2.0: + * Complete CASSANDRA-8448 fix (CASSANDRA-9519) * Don't include auth credentials in debug log (CASSANDRA-9682) * Can't transition from write survey to normal mode (CASSANDRA-9740) * Scrub (recover) sstables even when -Index.db is missing (CASSANDRA-9591) diff --git a/src/java/org/apache/cassandra/io/util/SequentialWriter.java b/src/java/org/apache/cassandra/io/util/SequentialWriter.java index e76add54a7..ee6e5b4c73 100644 --- a/src/java/org/apache/cassandra/io/util/SequentialWriter.java +++ b/src/java/org/apache/cassandra/io/util/SequentialWriter.java @@ -187,12 +187,30 @@ public class SequentialWriter extends OutputStream implements WritableByteChanne public void write(byte[] buffer) throws IOException { - write(ByteBuffer.wrap(buffer, 0, buffer.length)); + write(buffer, 0, buffer.length); } public void write(byte[] data, int offset, int length) throws IOException { - write(ByteBuffer.wrap(data, offset, length)); + if (buffer == null) + throw new ClosedChannelException(); + + int position = offset; + int remaining = length; + while (remaining > 0) + { + if (!buffer.hasRemaining()) + reBuffer(); + + int toCopy = Math.min(remaining, buffer.remaining()); + buffer.put(data, position, toCopy); + + remaining -= toCopy; + position += toCopy; + + isDirty = true; + syncNeeded = true; + } } public int write(ByteBuffer src) throws IOException