Skip to content

Commit

Permalink
chore(doc): fix doc example code (#1666)
Browse files Browse the repository at this point in the history
## What does this PR do?
according to comments,  should set `requireClassRegistration` to false


## Related issues


## Does this PR introduce any user-facing change?


- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?


## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
  • Loading branch information
wangjie-fourth committed May 31, 2024
1 parent 7ac2c6e commit 062bd76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ public class Example {
// multiple serializations of different objects.
{
Fury fury = Fury.builder().withLanguage(Language.JAVA)
// Allow to deserialize objects unknown types, more flexible
// but may be insecure if the classes contains malicious code.
.requireClassRegistration(true)
.build();
// Registering types can reduce class name serialization overhead, but not mandatory.
Expand All @@ -171,8 +169,6 @@ public class Example {
}
{
ThreadSafeFury fury = Fury.builder().withLanguage(Language.JAVA)
// Allow to deserialize objects unknown types, more flexible
// but may be insecure if the classes contains malicious code.
.requireClassRegistration(true)
.buildThreadSafeFury();
// Registering types can reduce class name serialization overhead, but not mandatory.
Expand Down
13 changes: 6 additions & 7 deletions docs/guide/java_serialization_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public class Example {
// Note that Fury instances should be reused between
// multiple serializations of different objects.
Fury fury = Fury.builder().withLanguage(Language.JAVA)
// Allow to deserialize objects unknown types, more flexible
// but may be insecure if the classes contains malicious code.
.requireClassRegistration(true)
.build();
// Registering types can reduce class name serialization overhead, but not mandatory.
Expand Down Expand Up @@ -80,11 +78,12 @@ import org.apache.fury.config.*;

public class Example {
// reuse fury.
private static final ThreadSafeFury fury = Fury.builder()
// Allow to deserialize objects unknown types, more flexible
// but may be insecure if the classes contains malicious code.
.requireClassRegistration(true)
.buildThreadSafeFury();
private static final ThreadSafeFury fury = new ThreadLocalFury(classLoader -> {
Fury f = Fury.builder().withLanguage(Language.JAVA)
.withClassLoader(classLoader).build();
f.register(SomeClass.class);
return f;
});

public static void main(String[] args) {
SomeClass object = new SomeClass();
Expand Down

0 comments on commit 062bd76

Please sign in to comment.