You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpEL解析器应返回true却返回false的异常问题求助

SpEL表达式解析异常排查求助

线上运行时,0.025%的流量(约200万请求中的500次)出现异常:SpEL解析器在本该返回true的情况下返回false。所有异常实例的processingModel值均为'SAMPLE',且解析过程未抛出异常、未返回null,主流程难以区分这些异常情况,特此求助排查原因。

上下文类代码

@Getter
@Builder
@ToString
public class EvaluationContext {
    private String requestKey;
    private String namespace;
    private ContextAmount totalAmount;
    private double threshold;
    private String processingModel;
    private String channel;
}

规则类代码

@Getter
@Setter
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class PolicyEvaluationRule {
    private String namespace;
    private String ruleName = "test1";
    private String expression = "'SAMPLE'.equals(Context?.ProcessingModel)";
    private EvaluationContext context;
}

SpEL规则求值代码

ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext(rule);
Boolean result = parser.parseExpression(rule.getExpression()).getValue(context, Boolean.class);

内容的提问来源于stack exchange,提问作者Prashant Chauhan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 14:35:54