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

Modify CompositeRequestDataValueProcessor #167

Closed
btkatoutkm opened this issue Oct 27, 2014 · 3 comments
Closed

Modify CompositeRequestDataValueProcessor #167

btkatoutkm opened this issue Oct 27, 2014 · 3 comments
Assignees
Milestone

Comments

@btkatoutkm
Copy link
Contributor

Change HashMap to LinkedHashMap.
Because tags order changed between java7 and java8.

@kazuki43zoo
Copy link
Contributor

@btkatoutkm @making

I think it is not a fundamental solution.
Because if the return type from delegated RequestDataValueProcessor was HashMap(contains multiple items), the order is not guaranteed.

How do your think?

@btkatoutkm
Copy link
Contributor Author

I think that RequestDataValueProcessor return HashMap(only one item) in this case.
Because line117「for (RequestDataValueProcessor processor : reversedProcessors)」 processing one by one.

And add to result(LikedHashMap) in order.

cf.CompositeRequestDataValueProcessor

private final List<RequestDataValueProcessor> reversedProcessors;

@Override
public Map<String, String> getExtraHiddenFields(HttpServletRequest request) {
    Map<String, String> result = new LinkedHashMap<String, String>();
    for (RequestDataValueProcessor processor : reversedProcessors) {
        Map<String, String> map = processor.getExtraHiddenFields(request);
        if (map != null) {
            result.putAll(map);
        }
    }
    return result;
}

cf.spring-mvc.xml

<bean name="requestDataValueProcessor"
    class="org.terasoluna.gfw.web.mvc.support.CompositeRequestDataValueProcessor">
    <constructor-arg>
        <util:list>
            <bean
                class="org.terasoluna.gfw.web.token.transaction.TransactionTokenRequestDataValueProcessor" />
            <bean
                class="org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor"
                factory-method="create" />
        </util:list>
    </constructor-arg>
</bean>

@making
Copy link
Contributor

making commented Oct 27, 2014

The order of the result from getExtraHiddenFields depends on implementations.
In this case, the order of DataValueProcessor is important.

Though the field name is "reversed processors", the following process ignores the order:

    Map<String, String> result = new HashMap<String, String>();
    for (RequestDataValueProcessor processor : reversedProcessors) {
        Map<String, String> map = processor.getExtraHiddenFields(request);
        if (map != null) {
            result.putAll(map);
        }
    }

So LinkedHashMap is right.

@making making added this to the 1.0.2 milestone Oct 27, 2014
making added a commit that referenced this issue Oct 27, 2014
…eRequestDataValueProcessor

Changed HashMap to LinkedHashMap #167
making added a commit that referenced this issue Oct 27, 2014
…eRequestDataValueProcessor

Changed HashMap to LinkedHashMap #167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants