chaokunyang commented on issue #2275:
URL: https://github.com/apache/fory/issues/2275#issuecomment-3260604832

   @julianhowarth could you try to run this code with 0.13.0-SNAPSHOT ? I run 
your code, but it didn't fail:
   
   ```java
   package org.apache.fory.format;
   
   import com.google.common.base.MoreObjects;
   
   import java.io.BufferedInputStream;
   import java.io.BufferedOutputStream;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.ObjectStreamException;
   import java.time.Instant;
   import java.util.Objects;
   import javax.annotation.CheckReturnValue;
   import javax.annotation.Nullable;
   import javax.annotation.ParametersAreNonnullByDefault;
   import javax.annotation.concurrent.Immutable;
   import org.apache.fory.Fory;
   import org.apache.fory.config.CompatibleMode;
   import org.apache.fory.config.Language;
   
   @ParametersAreNonnullByDefault
   @CheckReturnValue
   @Immutable
   public final class Bar {
     private final String value;
     private final int hashCode;
   
     private Bar(String value) {
       this.value = (String) Objects.requireNonNull(value, "value");
       this.hashCode = this.computeHashCode();
     }
   
     private Bar(Bar original, String value) {
       this.value = value;
       this.hashCode = this.computeHashCode();
     }
   
     public String getValue() {
       return this.value;
     }
   
     public final Bar withValue(String value) {
       String newValue = (String) Objects.requireNonNull(value, "value");
       return this.value.equals(newValue) ? this : new Bar(this, newValue);
     }
   
     public boolean equals(@Nullable Object another) {
       if (this == another) {
         return true;
       } else {
         return another instanceof Bar && this.equalTo(0, (Bar) another);
       }
     }
   
     private boolean equalTo(int synthetic, Bar another) {
       return this.hashCode != another.hashCode ? false : 
this.value.equals(another.value);
     }
   
     public int hashCode() {
       return this.hashCode;
     }
   
     private int computeHashCode() {
       int h = 5381;
       h += (h << 5) + this.value.hashCode();
       return h;
     }
   
     public String toString() {
       return MoreObjects.toStringHelper("RealmName")
         .omitNullValues()
         .add("value", this.value)
         .toString();
     }
   
     public static Bar of(String value) {
       return new Bar(value);
     }
   
     private Object readResolve() throws ObjectStreamException {
       return new Bar(this, this.value);
     }
     static void out() throws IOException {
       var fory = buildFory();
   
       var out = new File("out.fory");
       var outputStream = new BufferedOutputStream(new FileOutputStream(out));
   
       var item = new Foo(Bar.of("some-bar"));
   
       System.out.println(Instant.now() + " - writing data");
         outputStream.write(fory.serializeJavaObject(item));
       outputStream.flush();
       outputStream.close();
   
       System.out.println(Instant.now() + " - done");
     }
   
     static void in() throws IOException {
       var fory = buildFory();
   
       var in = new File("out.fory");
   
       System.out.println(Instant.now());
   
       var inputStream = new BufferedInputStream(new FileInputStream(in));
       var res = fory.deserializeJavaObject(inputStream.readAllBytes(), 
Foo.class);
   
       System.out.println(Instant.now() + " - loaded " + res);
     }
   
     private static Fory buildFory() {
       return Fory.builder()
         .withLanguage(Language.JAVA)
         .requireClassRegistration(false)
         .withCompatibleMode(CompatibleMode.COMPATIBLE)
         .build();
     }
     public static void main(String[] args) throws IOException {
       out();
       in();
     }
   }
   
   record Foo(Bar bar) {}
   ``` 
   
   <img width="2422" height="674" alt="Image" 
src="https://github.com/user-attachments/assets/86c3e84b-e5ea-456a-bf63-4ffe8585b7cb";
 />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to