PropertyOrFieldReference avoids NPE through defensive copy of volatile accessor reference
Issue: SPR-13023
This commit is contained in:
parent
0711d6d0df
commit
9799df397a
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -80,8 +80,9 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
||||||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||||
TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(),
|
TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(),
|
||||||
state.getConfiguration().isAutoGrowNullReferences());
|
state.getConfiguration().isAutoGrowNullReferences());
|
||||||
if (this.cachedReadAccessor instanceof CompilablePropertyAccessor) {
|
PropertyAccessor accessorToUse = this.cachedReadAccessor;
|
||||||
CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) this.cachedReadAccessor;
|
if (accessorToUse instanceof CompilablePropertyAccessor) {
|
||||||
|
CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) accessorToUse;
|
||||||
this.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
|
this.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
|
||||||
}
|
}
|
||||||
return tv;
|
return tv;
|
||||||
|
@ -338,13 +339,18 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompilable() {
|
public boolean isCompilable() {
|
||||||
return (this.cachedReadAccessor instanceof CompilablePropertyAccessor &&
|
PropertyAccessor accessorToUse = this.cachedReadAccessor;
|
||||||
((CompilablePropertyAccessor) this.cachedReadAccessor).isCompilable());
|
return (accessorToUse instanceof CompilablePropertyAccessor &&
|
||||||
|
((CompilablePropertyAccessor) accessorToUse).isCompilable());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
||||||
((CompilablePropertyAccessor) this.cachedReadAccessor).generateCode(this.name, mv, cf);
|
PropertyAccessor accessorToUse = this.cachedReadAccessor;
|
||||||
|
if (!(accessorToUse instanceof CompilablePropertyAccessor)) {
|
||||||
|
throw new IllegalStateException("Property accessor is not compilable: " + accessorToUse);
|
||||||
|
}
|
||||||
|
((CompilablePropertyAccessor) accessorToUse).generateCode(this.name, mv, cf);
|
||||||
cf.pushDescriptor(this.exitTypeDescriptor);
|
cf.pushDescriptor(this.exitTypeDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue