I am trying to setup a @ConditionalExpression with the use of environment variables as follows:
@ConditionalOnExpression("#{systemEnvironment['PUBLIC']?:'false'} != true")
I can see this is evaluated within following code:
private Boolean evaluateExpression(ConfigurableListableBeanFactory beanFactory, String expression) {
BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver();
if (resolver == null) {
resolver = new StandardBeanExpressionResolver();
}
BeanExpressionContext expressionContext = new BeanExpressionContext(beanFactory, null);
Object result = resolver.evaluate(expression, expressionContext);
return (result != null && (boolean) result);
}
The problem is that the resolver.evaluate(expression, expressionContext); returns false != true where this should already be a boolean:
return (result != null && (boolean) result);
So this always fails with ClassCastException.
I tried also to fiddle with different kind of quoting and wrapping it whole with ${…}, but always with the same result.
Question is: What is wrong with my conditional expression?