odnoklassniki / one-nio

Unconventional I/O library for Java
Apache License 2.0
648 stars 96 forks source link

BigDecimal with new Java does not work any more #67

Closed MacX19 closed 1 year ago

MacX19 commented 1 year ago

Deserialization BigDecimal with Java 1.8.0_351 does not work any more:

java.io.IOException: readObject() is not fully supported. See implementation notes.
    at one.nio.serial.gen.NullObjectInputStream.unsupported(NullObjectInputStream.java:170)
    at one.nio.serial.gen.NullObjectInputStream.readFields(NullObjectInputStream.java:50)
    at java.math.BigDecimal.readObject(BigDecimal.java:3798)
    at sun.reflect.Delegate14_BigDecimal.read(Unknown Source)
    at one.nio.serial.GeneratedSerializer.read(GeneratedSerializer.java:127)
    at one.nio.serial.DeserializeStream.readObject(DeserializeStream.java:75)
...
mikhailusachev commented 1 year ago

Could you please provide a minimal testcase to reproduce?

MacX19 commented 1 year ago

Could you please provide a minimal testcase to reproduce?

Java 1.8.0_351 one-nio 1.6.0

    byte[] res;
    try (PersistStream stream = new PersistStream()) {
      BigDecimal bigDecimal = new BigDecimal("12.34");
      stream.writeObject(bigDecimal);
      res = stream.toByteArray();
    }
    try (DeserializeStream des = new DeserializeStream(res)) {
      System.out.println(des.readObject());
    }
Exception in thread "main" java.io.IOException: readObject() is not fully supported. See implementation notes.
    at one.nio.serial.gen.NullObjectInputStream.unsupported(NullObjectInputStream.java:170)
    at one.nio.serial.gen.NullObjectInputStream.readFields(NullObjectInputStream.java:50)
    at java.math.BigDecimal.readObject(BigDecimal.java:3798)
    at sun.reflect.Delegate0_BigDecimal.read(Unknown Source)
    at one.nio.serial.GeneratedSerializer.read(GeneratedSerializer.java:127)
    at one.nio.serial.DeserializeStream.readObject(DeserializeStream.java:75)
...
dormidon commented 1 year ago

@MacX19 , thank you for the report and the example. We have tried to fix it in 1.6.1 release. Could you please check if the issue is still actual or fixed?

MacX19 commented 1 year ago

Looks like it's working properly now