Simplify implementation of internal VariableNotAvailableException
Since VariableNotAvailableException is not a public type, there is no need to store the variable name in a field/property.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,12 +25,12 @@ import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Cache specific evaluation context that adds a method parameters as SpEL
|
||||
* variables, in a lazy manner. The lazy nature eliminates unneeded
|
||||
* parsing of classes byte code for parameter discovery.
|
||||
* Cache-specific evaluation context that adds method parameters as SpEL
|
||||
* variables, in a lazy manner. The lazy nature avoids unnecessary
|
||||
* parsing of a class's byte code for parameter discovery.
|
||||
*
|
||||
* <p>Also define a set of "unavailable variables" (i.e. variables that should
|
||||
* lead to an exception right the way when they are accessed). This can be useful
|
||||
* <p>Also defines a set of "unavailable variables" (i.e. variables that should
|
||||
* lead to an exception as soon as they are accessed). This can be useful
|
||||
* to verify a condition does not match even when not all potential variables
|
||||
* are present.
|
||||
*
|
||||
@@ -55,10 +55,10 @@ class CacheEvaluationContext extends MethodBasedEvaluationContext {
|
||||
|
||||
|
||||
/**
|
||||
* Add the specified variable name as unavailable for that context.
|
||||
* Any expression trying to access this variable should lead to an exception.
|
||||
* <p>This permits the validation of expressions that could potentially a
|
||||
* variable even when such variable isn't available yet. Any expression
|
||||
* Add the specified variable name as unavailable for this context.
|
||||
* <p>Any expression trying to access this variable should lead to an exception.
|
||||
* <p>This permits the validation of expressions that could potentially access
|
||||
* a variable even when such a variable isn't available yet. Any expression
|
||||
* trying to use that variable should therefore fail to evaluate.
|
||||
*/
|
||||
public void addUnavailableVariable(String name) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cache.interceptor;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
|
||||
/**
|
||||
* A specific {@link EvaluationException} to mention that a given variable
|
||||
* used in the expression is not available in the context.
|
||||
* An internal {@link EvaluationException} which signals that a given variable
|
||||
* used in an expression is not available in the context.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.0.6
|
||||
@@ -28,17 +28,8 @@ import org.springframework.expression.EvaluationException;
|
||||
@SuppressWarnings("serial")
|
||||
class VariableNotAvailableException extends EvaluationException {
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
public VariableNotAvailableException(String name) {
|
||||
super("Variable not available");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
super("Variable '" + name + "' not available");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user