Skip to content

Commit

Permalink
test(core): demonstrate behavior of SpEL expression evaluation (#4762)
Browse files Browse the repository at this point in the history
that uses a non-public constructor/method, and so requires special treatment under java 17.
  • Loading branch information
dbyron-sf authored Jul 8, 2024
1 parent f5e2d29 commit 6d8a721
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ subprojects {
}
}

// This is required for some SpEL expressions to evaluate properly with java
// 17. It works with java 11 as well, but isn't required there.
tasks.withType(Test).configureEach {
jvmArgs += '--add-opens=java.base/java.util=ALL-UNNAMED'
}

if (name != "orca-bom" && name != "orca-api") {
apply plugin: "java-library"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ class PipelineExpressionEvaluatorSpec extends Specification {
'${status == "SUCCEEDED"}' | false
}

def "allows calling toString on an UnmodifiableMap"() {
given:
// This fails under java 17 without something like
// --add-opens=java.base/java.util=ALL-UNNAMED as an argument ot the jvm.
def source = [test: '${ {"foo": "bar"}.toString() }']
PipelineExpressionEvaluator evaluator = new PipelineExpressionEvaluator([], pluginManager, expressionProperties)

when:
ExpressionEvaluationSummary evaluationSummary = new ExpressionEvaluationSummary()
def result = evaluator.evaluate(source, [status: ExecutionStatus.TERMINAL], evaluationSummary, true)

then:
evaluationSummary.expressionResult.isEmpty()
evaluationSummary.failureCount == 0
result.test == '{foo=bar}'
}

static ExpressionFunctionProvider buildExpressionFunctionProvider(String providerName) {
new ExpressionFunctionProvider() {
@Override
Expand Down

0 comments on commit 6d8a721

Please sign in to comment.