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

Serializee is a managed class and we should use always an injected instance #839

Merged
merged 1 commit into from
Oct 17, 2014

Conversation

garcia-jj
Copy link
Member

This change breaks compatibility because change constructor signature. Of course only for users who extends serialization internal classes. No public API was changed.

But this change is really necessary because we are not using managed Serializee for all classes. There are some places that uses a non managed instance that isn't the same instance in the places that uses managed instance.

…stance

Signed-off-by: Otávio Garcia <otavio@otavio.com.br>
@Turini
Copy link
Member

Turini commented Oct 17, 2014

+1 for this change. Did you test in a real app?

@@ -36,11 +36,12 @@
public class VRaptorClassMapper extends MapperWrapper {

private final Supplier<TypeNameExtractor> extractor;
private final Serializee serializee = new Serializee();
private final Supplier<Serializee> serializee;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the benefit of using Supplier here. Can you explain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the VRaptorXStream.wrapMapper is called by super constructor when XStream is instantiated. So we get a null instance because the injection is only did after instantiation. So we need to use lazy instance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and Instance won't solve this problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh my dear lord, good point. Where is my head that I don't think in this? I'll try some tests with Instance. Thank you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Turini I think that is better to leave as is, because this class is vetoed, and receives instances from VRaptorXStream that is vetoed too, that receives instances from XStreamBuilderImpl. I tried to take this change, and a lot of classes will be changed its contructors to receive Instance<> instead of the object.

And more: there are some classes used in tests like MockSerializationResult, forcing users to rewrite their classes when migrate.

What you think to leave as is, with Supplier? Do you want I send to you a patch with changes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, we can use Supplier :) so 🚢

@garcia-jj
Copy link
Member Author

Yes, I did this test in my personal app. I've tested Json and XML serialization, and works fine.

garcia-jj added a commit that referenced this pull request Oct 17, 2014
Serializee is a managed class and we should use always an injected instance
@garcia-jj garcia-jj merged commit 6294a5b into master Oct 17, 2014
@garcia-jj garcia-jj deleted the ot-badserializee branch October 17, 2014 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants