fury icon indicating copy to clipboard operation
fury copied to clipboard

java.lang.IndexOutOfBoundsException when use withStringCompressed(true)

Open wzhongke opened this issue 1 year ago • 4 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Version

0.9.0

Component(s)

Java

Minimal reproduce step

public class Main {
    private static final ThreadSafeFury FURY = Fury.builder().withLanguage(Language.JAVA)
        .requireClassRegistration(false)
        .withNumberCompressed(true)
        .withStringCompressed(true)
        .withRefTracking(true)
        .withMetaCompressor(new DeflaterMetaCompressor())
        .buildThreadLocalFury();

    @Data
    public static class Simple {
        private String str;

        public Simple(String str) {
            this.str = str;
        }
    }

    public static void main(String[] args) {
        byte[] serialize = FURY.serialize(new Simple("STG@ON DEMAND Solutions@GeoComputing Switch/ Hub@Digi Edgeport/216 – 16 port Serial Hub"));
        FURY.deserialize(serialize);
    }
}

What did you expect to see?

No error

What did you see instead?

Exception in thread "main" org.apache.fury.exception.DeserializationException: Deserialize failed, read objects are: [Main.Simple(str=null)] at org.apache.fury.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:63) at org.apache.fury.Fury.deserialize(Fury.java:797) at org.apache.fury.Fury.deserialize(Fury.java:714) at org.apache.fury.ThreadLocalFury.deserialize(ThreadLocalFury.java:137) at com.lenovo.awakens.Main.main(Main.java:33) Caused by: java.lang.IndexOutOfBoundsException: readerIndex(30) + length(81) exceeds size(123): org.apache.fury.memory.MemoryBuffer$BoundChecker@2584b82d at org.apache.fury.memory.MemoryBuffer$BoundChecker.fillBuffer(MemoryBuffer.java:186) at org.apache.fury.memory.MemoryBuffer.checkReadableBytes(MemoryBuffer.java:2412) at org.apache.fury.serializer.StringSerializer.readBytesUnCompressedUTF16(StringSerializer.java:434) at org.apache.fury.serializer.StringSerializer.readBytesString(StringSerializer.java:206) at com.lenovo.awakens.Main_SimpleFuryRefCodec_0.read(Main_SimpleFuryRefCodec_0.java:56) at org.apache.fury.Fury.readDataInternal(Fury.java:959) at org.apache.fury.Fury.readRef(Fury.java:861) at org.apache.fury.Fury.deserialize(Fury.java:793) ... 3 more

Anything Else?

I think it might be a problem here, but I am not sure about it image

Are you willing to submit a PR?

  • [X] I'm willing to submit a PR!

wzhongke avatar Dec 19 '24 06:12 wzhongke

@HuangXingBo Could you take a look at this issue? Seems we should check compressString before returning new Invoke(strSerializer, "readBytesString", STRING_TYPE, buffer), and we also need an ut which test a POJO with String field serialization with codegen enabled

chaokunyang avatar Dec 19 '24 07:12 chaokunyang

Hi @wzhongke , could you disable string compression? This will keep behaviour consistent with fury 0.8.0. The serialization will still work. Of course the serialized data will be larger.

chaokunyang avatar Dec 19 '24 07:12 chaokunyang

Hi @wzhongke , could you disable string compression? This will keep behaviour consistent with fury 0.8.0. The serialization will still work. Of course the serialized data will be larger.

OK, thanks

wzhongke avatar Dec 19 '24 08:12 wzhongke

@wzhongke Would you like to create a PR to fix this? We can make a release in next two weeks

chaokunyang avatar Dec 19 '24 08:12 chaokunyang