-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support to use application-fury in resteasy #26
Conversation
@chaokunyang can you take a look at the native test failure. It seems that int f1, string f2 In JVM mode, it is deserialized into
|
@chaokunyang if there two class have the same fields, like class A {
int a;
String b;
}
class B {
int a;
String b;
}
It should be serialze into the same bytes, right? during deserilzing, how `fury` can detect which class type should be used? |
Fury generated codec is cached into a global map, maybe they have a conflict. When creating ThreadSafeFury, we could a different name by FuryBuilder#withName to avoid cache conflict. |
Maybe We could Set name to timestamp for tests |
Hmm, another found that public class BarSerializer extends Serializer<Bar> {
public BarSerializer(Fury fury, Class<Bar> type) {
super(fury, type);
}
@Override
public void write(MemoryBuffer buffer, Bar value) {
buffer.writeVarInt32(value.f1());
fury.writeJavaString(buffer, value.f2());
}
@Override
public Bar read(MemoryBuffer buffer) {
return new Bar(buffer.readVarInt32(), fury.readJavaString(buffer));
}
} |
@Consumes({ "application/fury", "application/*+fury" }) | ||
@Produces({ "application/fury", "application/*+fury" }) | ||
public class ClassicFurySerializer implements MessageBodyReader<Object>, MessageBodyWriter<Object> { | ||
private BaseFury fury; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add @Inject
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, it shoudl work. Let me try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not work. Because resteasy will init the providers at static_init time where the bean container is not running. We have to retrieve BaseFury
at runtime. see
They are all caused by cache conflict, I fixed it in #27 |
OK, I will check with your fix. Thanks a lot! |
Sorry @chaokunyang - your fix looks not working! |
integration-tests/src/test/java/io/quarkiverse/fury/it/FuryTest.java
Outdated
Show resolved
Hide resolved
public void testFuryBar() { | ||
Bar bar = new Bar(1, "hello bar"); | ||
Fury fury = Fury.builder().requireClassRegistration(true).withName("Fury" + System.nanoTime()).build(); | ||
fury.register(Bar.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't write code like this, the serialization and deserialization should have same class registration order. If you register Bar here, it allocate an ID x for Bar, but the server allocate id x for ThirdPartyBar. This is why it fails. You could update like this:
@FurySerialization(classId=200)
class Bar {
...
}
fury.register(Bar.class, 200);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the root cause. Thanks a lot @chaokunyang ! Should we need a NOTE in the documentation or refer to the Apache Fury docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would you like submit a pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean a PR for Fury
?
This will support to use
application/fury
as a mediatype and de(serialize) objects over the HTTP connections.see
testFuryBar()
method.