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

VariableMapperWrapper: typo + generics + code clarification #5520

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class VariableMapperWrapper extends VariableMapper {

private final VariableMapper target;

private Map vars;
private Map<String,ValueExpression> vars;

/**
* @param orig the original variable mapper to be wrapped
Expand All @@ -46,22 +46,18 @@ public VariableMapperWrapper(VariableMapper orig) {
}

/**
* First tries to resolve agains the inner Map, then the wrapped ValueExpression.
* First tries to resolve against the inner Map, then the wrapped ValueExpression.
*
* @see jakarta.el.VariableMapper#resolveVariable(java.lang.String)
*/
@Override
public ValueExpression resolveVariable(String variable) {
ValueExpression ve = null;
try {
if (vars != null) {
ve = (ValueExpression) vars.get(variable);
}
if (ve == null) {
return target.resolveVariable(variable);
}
return ve;
} catch (StackOverflowError e) {
// note that vars may contain null values so we can't use vars.getOrDefault
final ValueExpression ve = (vars != null ? vars.get(variable) : null);
return ve != null ? ve : target.resolveVariable(variable);
}
catch (StackOverflowError e) {
throw new ELException("Could not Resolve Variable [Overflow]: " + variable, e);
}
}
Expand All @@ -74,8 +70,8 @@ public ValueExpression resolveVariable(String variable) {
@Override
public ValueExpression setVariable(String variable, ValueExpression expression) {
if (vars == null) {
vars = new HashMap();
vars = new HashMap<>();
}
return (ValueExpression) vars.put(variable, expression);
return vars.put(variable, expression);
}
}
Loading