-
Notifications
You must be signed in to change notification settings - Fork 332
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
fixing problem with null headers #631
Conversation
Header have more priority than request parameters. With this code if header |
@garcia-jj it makes sense, but should we do a considerably much more complex code to support it? it seems like an unlikely corner case |
@lucascs Why IOGI don't accept null values? The exception is: Adding a |
If not, we can change the docs explaining that header only override request parameters if is not null. |
null is the billion dollar mistake. It's evil. I wouldn't add the docs, because it will only confuse the user. I don't think there is a fair use case when we'd use a Anyway, we could (perhaps should) implement the something like
what do you think? |
I agree that But, for me, I like your suggestion. +1 |
@lucascs and @garcia-jj, I can changed ParameterInstantiator from: for (int i = 0; i < valuedParameters.length; i++) {
valuedParameters[i].setValue(values[i]);
} to something like that: for (int i = 0; i < valuedParameters.length; i++) {
Parameter parameter = valuedParameters[i].getParameter();
boolean hasHeaderParam = parameter.isAnnotationPresent(HeaderParam.class);
if (!hasHeaderParam && headerValues.contains(valuedParameters[i].getName())) {
continue;
}
valuedParameters[i].setValue(values[i]);
} and it will works (I've tested). But the code seems really ugly. Ideas? |
I guess the correct way would be something like: for (int i = 0; i < valuedParameters.length; i++) {
Parameter parameter = valuedParameters[i].getParameter();
boolean hasHeaderParam =
if (parameter.isAnnotationPresent(HeaderParam.class)) {
valuedParameters[i].setValue(request.getHeader(<...>));
} else {
valuedParameters[i].setValue(values[i]);
}
} maybe we need to use converters before setting the value, in this case. |
I don't have an opinion about this change. @lucascs idea sounds good for me. But if we need to call converters, so I think that we only need to override only if header is not null. |
If the header is null, we have to set null (or call the converter to maybe provide a good null object) |
I see your point. Fair enough. |
I've updated the code with Lucas' suggestions. What do you think? |
This way you only support String headers... but there are other types of headers, like "If-Modified-Since" (date-time), "Location" (URI), Content-Length (long), If-None-Match (list of e-tags, which could be a value object). Converters would help with this. |
Ready to me supporting only strings by now. |
I agree. What do you think @lucascs? |
It's kinda a breaking change if you only support Strings... but I don't know how many people use this feature. |
what about to merge it and open an issue? |
I think it's a good idea by now. When is the next release of VRaptor final version ? |
really soon :) |
Good. :) |
I agree with you. Merge and wait users ask for object support. |
agreed, merging it. |
fixing problem with null headers
Closes #595.