Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): Compatible mode on de/serialize api failed to deserialize #1996

Merged
merged 11 commits into from
Jan 7, 2025
Prev Previous commit
Next Next commit
fix: documentation
orisgarno committed Jan 7, 2025
commit bd0e757fad4f94a16ff8904601287637770b7df9
10 changes: 6 additions & 4 deletions docs/guide/java_serialization_guide.md
Original file line number Diff line number Diff line change
@@ -510,10 +510,6 @@ If you create fury without setting `CompatibleMode` to `org.apache.fury.config.C
strange
serialization error, it may be caused by class inconsistency between serialization peer and deserialization peer.

If you create fury and set `CompatibleMode` to `org.apache.fury.config.CompatibleMode.COMPATIBLE`, you need to register
the class that you want to serialize or deserialize(You don't need to register any class inside that class).
[See example here](/java/fury-core/src/test/java/org/apache/fury/serializer/compatible/CompatibleSerializerTest.java)

In such cases, you can invoke `FuryBuilder#withClassVersionCheck` to create fury to validate it, if deserialization
throws `org.apache.fury.exception.ClassNotCompatibleException`, it shows class are inconsistent, and you should create
fury with
@@ -522,6 +518,12 @@ fury with
`CompatibleMode.COMPATIBLE` has more performance and space cost, do not set it by default if your classes are always
consistent between serialization and deserialization.

### Different POJO deserialization
Fury allows you to serialize one POJO and deserialize it into a different POJO. To achieve this, configure Fury with
`CompatibleMode` set to `org.apache.fury.config.CompatibleMode.COMPATIBLE`. Additionally, you only need to register the
specific classes you want to serialize or deserialize; there's no need to register any nested classes within them.
[See example here](/java/fury-core/src/test/java/org/apache/fury/serializer/compatible/DifferentPOJOCompatibleSerializerTest.java)

### Use wrong API for deserialization

If you serialize an object by invoking `Fury#serialize`, you should invoke `Fury#deserialize` for deserialization
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
* class with different name - scrambled field order to make sure it could handle different field
* order - missing or extra field from source class to target class - generic class
*/
public class CompatibleSerializerTest extends Assert {
public class DifferentPOJOCompatibleSerializerTest extends Assert {

Fury getFury(Class<?>... classes) {
Fury instance =
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
import org.apache.fury.test.bean.BeanA;
import org.testng.annotations.Test;

public class DataTypeTest {
public class DataTypesTest {

@Test
public void parseSchema() {

Unchanged files with check annotations Beta

name: Rust CI
strategy:
matrix:
os: [ubuntu-latest, macos-13, macos-14] # macos-13: x86, macos-14: arm64

Check warning on line 188 in .github/workflows/ci.yml

GitHub Actions / 🍏 YAML

188:49 [comments] too few spaces before comment
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
name: C++ CI
strategy:
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-2022] # macos-13: x86, macos-14: arm64

Check warning on line 204 in .github/workflows/ci.yml

GitHub Actions / 🍏 YAML

204:63 [comments] too few spaces before comment
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4