|
2 | 2 |
|
3 | 3 | import com.google.common.base.CaseFormat; |
4 | 4 | import com.google.common.collect.ImmutableSet; |
5 | | -import com.hubspot.jinjava.JinjavaConfig; |
6 | 5 | import com.hubspot.jinjava.interpret.DeferredValueException; |
7 | 6 | import com.hubspot.jinjava.interpret.JinjavaInterpreter; |
8 | 7 | import com.hubspot.jinjava.util.EagerReconstructionUtils; |
|
16 | 15 | import java.util.LinkedList; |
17 | 16 | import java.util.List; |
18 | 17 | import java.util.Map; |
19 | | -import java.util.Objects; |
20 | 18 | import java.util.Set; |
21 | 19 | import java.util.concurrent.ConcurrentHashMap; |
22 | 20 | import javax.el.ELContext; |
@@ -222,30 +220,26 @@ protected Method findMethod( |
222 | 220 | .orElseGet(() -> potentialMethods.stream().findAny().orElse(finalVarArgsMethod) |
223 | 221 | ); |
224 | 222 | } |
225 | | - return getJinjavaConfig().getMethodValidator().validateMethod(method); |
| 223 | + return getAllowlistMethodValidator().validateMethod(method); |
226 | 224 | } |
227 | 225 |
|
228 | 226 | @Override |
229 | 227 | protected Method getWriteMethod(Object base, Object property) { |
230 | | - return getJinjavaConfig() |
231 | | - .getMethodValidator() |
| 228 | + return getAllowlistMethodValidator() |
232 | 229 | .validateMethod(super.getWriteMethod(base, property)); |
233 | 230 | } |
234 | 231 |
|
235 | 232 | @Override |
236 | 233 | protected Method getReadMethod(Object base, Object property) { |
237 | | - return getJinjavaConfig() |
238 | | - .getMethodValidator() |
| 234 | + return getAllowlistMethodValidator() |
239 | 235 | .validateMethod(super.getReadMethod(base, property)); |
240 | 236 | } |
241 | 237 |
|
242 | | - private static JinjavaConfig getJinjavaConfig() { |
243 | | - return Objects |
244 | | - .requireNonNull( |
245 | | - JinjavaInterpreter.getCurrent(), |
246 | | - "JinjavaInterpreter.closeablePushCurrent must be used if using a JinjavaBeanELResolver directly" |
247 | | - ) |
248 | | - .getConfig(); |
| 238 | + private static AllowlistMethodValidator getAllowlistMethodValidator() { |
| 239 | + return JinjavaInterpreter |
| 240 | + .getCurrentMaybe() |
| 241 | + .map(interpreter -> interpreter.getConfig().getMethodValidator()) |
| 242 | + .orElse(AllowlistMethodValidator.DEFAULT); |
249 | 243 | } |
250 | 244 |
|
251 | 245 | private static boolean checkAssignableParameterTypes(Object[] params, Method method) { |
|
0 commit comments