From f003f13ba38c631d6edc4724dc4059215b891814 Mon Sep 17 00:00:00 2001 From: leventov Date: Sat, 20 Jun 2015 07:21:01 +0300 Subject: [PATCH] Fix compilation --- .../internal/CharSequenceReader.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/internal/CharSequenceReader.java b/src/main/java/net/openhft/chronicle/hash/serialization/internal/CharSequenceReader.java index 32e608f49..c69d260e0 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/internal/CharSequenceReader.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/internal/CharSequenceReader.java @@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.ObjectStreamException; import java.io.Serializable; +import java.io.UTFDataFormatException; public final class CharSequenceReader implements BytesReader, StatefulCopyable> { @@ -81,12 +82,32 @@ public final class CharSequenceReader this.identity = identity; } + /** + * Method copied here because corresponding method in AbstractBytes was turned + * to instance method, but we need to call on Bytes, not AbstractBytes + */ + private static void readUTF0(Bytes b, @NotNull Appendable appendable, int utflen) + throws IOException { + int count = 0; + + while (count < utflen) { + int c = b.readUnsignedByteOrThrow(); + if (c >= 128) { + b.position(b.position() - 1); + AbstractBytes.readUTF2(b, appendable, utflen, count); + break; + } + count++; + appendable.append((char) c); + } + } + @NotNull @Override public S read(@NotNull Bytes bytes, long size) { sb.setLength(0); try { - AbstractBytes.readUTF0(bytes, sb, (int) size); + readUTF0(bytes, sb, (int) size); } catch (IOException e) { throw new IllegalStateException(e); } @@ -109,7 +130,7 @@ public final class CharSequenceReader appendable = sb; } try { - AbstractBytes.readUTF0(bytes, appendable, (int) size); + readUTF0(bytes, appendable, (int) size); } catch (IOException e) { throw new IllegalStateException(e); }