Skip to content

Commit 281707c

Browse files
authored
Merge pull request #3878 from evolvedbinary/refactor/inner-class
Remove object retained by inner-class via back-reference
2 parents 385b14e + 3586675 commit 281707c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

exist-core/src/main/java/org/exist/xquery/CastExpression.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,31 @@ public Function toFunction() throws XPathException {
193193
final SequenceType argType = new SequenceType(Type.ITEM, Cardinality.EXACTLY_ONE);
194194
signature.setArgumentTypes(new SequenceType[]{argType});
195195
signature.setReturnType(new SequenceType(CastExpression.this.requiredType, CastExpression.this.cardinality));
196-
return new FunctionWrapper(context, signature);
196+
return new FunctionWrapper(this, signature);
197197
} catch (final QName.IllegalQNameException e) {
198198
throw new XPathException(ErrorCodes.XPST0081, "No namespace defined for prefix " + typeName);
199199
}
200200
}
201201

202-
private class FunctionWrapper extends Function {
202+
private static class FunctionWrapper extends Function {
203+
private final CastExpression castExpression;
203204

204-
protected FunctionWrapper(XQueryContext context, FunctionSignature signature) throws XPathException {
205-
super(context, signature);
205+
protected FunctionWrapper(final CastExpression castExpression, final FunctionSignature signature) throws XPathException {
206+
super(castExpression.getContext(), signature);
206207
final List<Expression> args = new ArrayList<>(1);
207-
args.add(new Function.Placeholder(context));
208+
args.add(new Function.Placeholder(castExpression.getContext()));
208209
super.setArguments(args);
210+
this.castExpression = castExpression;
209211
}
210212

211213
@Override
212-
public void setArguments(List<Expression> arguments) throws XPathException {
213-
CastExpression.this.setExpression(arguments.get(0));
214+
public void setArguments(final List<Expression> arguments) throws XPathException {
215+
castExpression.setExpression(arguments.get(0));
214216
}
215217

216218
@Override
217219
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
218-
return CastExpression.this.eval(contextSequence);
220+
return castExpression.eval(contextSequence);
219221
}
220222
}
221223
}

0 commit comments

Comments
 (0)