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

Change the event that the DeserializingObserver is listening to #425

Closed
renatorroliveira opened this issue Mar 6, 2014 · 18 comments
Closed
Assignees
Labels
Milestone

Comments

@renatorroliveira
Copy link
Collaborator

Hello guys,
I am suggesting to change the event that the DeserializingObserver is listening to.
Today it is listening to the ReadyToExecuteMethod, which is the same event that the MethodValidator is listening.
This is producing a bug in the validator. This happens because with the CDI events we can't guarantee the order of the listerner's execution. So, in my tests, when i receive the parameters of my controller's method via JSON, i annotated the method with @consumes. However, the listener of the MethodValidator is beeing executed before the DeserializingObserver. So, when i call validator.onError... it always acuses validation errors, because the validation is occurring before the processing of parameters.

So, the DeserializingObserver should be listening to another event, an event that occurs before the ReadyToExecuteMethod. It could be an existent or even a new event.

Regards

@Turini Turini self-assigned this Mar 6, 2014
@Turini Turini added this to the 4.1 milestone Mar 6, 2014
@Turini Turini added the bug label Mar 6, 2014
@Turini
Copy link
Member

Turini commented Mar 6, 2014

Thank you for reporting @renatorroliveira! I'll do some tests

@garcia-jj
Copy link
Member

As discussed in #366, we need to review events fired on each request.

@renatorroliveira
Copy link
Collaborator Author

Yeah, but i think this bug should be corrected as soon as possible.
We cannot use the Bean Validator with @consumes at this point, it doesn't work.
The correction is kind simple, i suggest creating a new event that is fired before ReadyToExecuteMethod or, if you don't want to create new events, execute the DeserializingObserver right after the normal parameter processing.

@Turini
Copy link
Member

Turini commented Mar 6, 2014

@renatorroliveira, may you test with this PR (#426) code?

@Turini
Copy link
Member

Turini commented Mar 6, 2014

just explaining, EndOfInterceptorStack is fired just before ReadyToExecuteMethod

@renatorroliveira
Copy link
Collaborator Author

I will test as soon as i got home today.
But taking a look at the pull request, you set the MethodValidator to execute before ReadyToExecuteMethod. But that was the problem, the DeserializingObserver should execute before the MethodValidator, with this code the MethodValidator will always execute before the DeserializingObserver?
I think this is the inverse order...

@Turini
Copy link
Member

Turini commented Mar 6, 2014

you're right @renatorroliveira! rs. I'll fix in there, thanks again

@renatorroliveira
Copy link
Collaborator Author

I think it should be the DeserializingObserver listening to EndOfInterceptorStack and the MethodValidator listening to ReadyToExecuteMethod.
But this still have a problem, because the ExecuteMethod is listening to EndOfInterceptorStack too, and you can't guarantee that the ExecuteMethod will be called after any other listener of the EndOfInterceptorStack...

@Turini
Copy link
Member

Turini commented Mar 6, 2014

I'm adding a new event, because in this case it will be really necessary.

@garcia-jj
Copy link
Member

I have commited some weeks ago a similar case: https://github.com/garcia-jj/vraptor4/commits/ot-rejectednewobservers. May be you can do somethink like this, if you want.

@Turini
Copy link
Member

Turini commented Mar 6, 2014

@renatorroliveira, can you test now? (with #427 changes)

@Turini
Copy link
Member

Turini commented Mar 6, 2014

I have commited some weeks ago a similar case: https://github.com/garcia-jj/vraptor4
/commits/ot-rejectednewobservers. May be you can do somethink like this, if you want.

thanks @garcia-jj.

@Turini Turini modified the milestone: 4.0.0-RCF Mar 6, 2014
@Turini
Copy link
Member

Turini commented Mar 7, 2014

@renatorroliveira, we replace #427 solution with #430.
Now Deserializing observes StackStarting, so it should solve the issue.
When it's possible, could you test with #430 code?

@renatorroliveira
Copy link
Collaborator Author

I will try to do some tests, i don't know how to get the specific code of the pull request, but i will look for it.

@renatorroliveira
Copy link
Collaborator Author

I've got the branch code. I will do some tests now.
But looking at the solution, i think this will solve the problem if the deserialization happens before the interceptor executor. I will post the test results later.

@Turini
Copy link
Member

Turini commented Mar 9, 2014

thanks @renatorroliveira! If you need any help, just let me know =)

@renatorroliveira
Copy link
Collaborator Author

Hi @Turini
Looks like the problem was solved with the #430 solved the problem!
I finally get the branch's code to work with my project =P

In my tests the deserialization and the validation worked fine.
Who should close this issue?

@Turini
Copy link
Member

Turini commented Mar 11, 2014

great @renatorroliveira! I'll merge this PR, and it will close the issue automatically

@Turini Turini closed this as completed in b9d7d5e Mar 11, 2014
Turini added a commit that referenced this issue Mar 11, 2014
Deserializing observing StackStarting. Closes #425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants