camunda/feel-scala

Can't access suppressed failures of an EvaluationResult from Java

Opened this issue · 1 comments

Describe the bug
From a Java application, I can't access the suppressed failures of an EvaluationResult smoothly. The result returns the failures as a Scala list that is not easy to consume from Java code. See here

To Reproduce
Steps to reproduce the behavior:

  1. From Java code, access the suppressed failures of an EvaluationResult.
final java.util.List<EvaluationFailure> failures = result.suppressedFailures();
  1. Verify that the code snipped doesn't compile because it returns a Scala list

Expected behavior
From Java code, I can't access the list of evaluation failures natively (i.e. without any type transformation).

Related to #539.

Environment

  • FEEL engine version: 1.17.0
  • Affects:
    • Camunda Automation Platform 7: [7.x]
    • Zeebe broker: [0.x]

Workaround

In my Java code, I use the following snippet to collect the suppressed failures:

private static List<FeelEvaluationWarning> collectEvaluationWarnings(EvaluationResult result) {
    final var warnings = new ArrayList<FeelEvaluationWarning>();
    result
        .suppressedFailures()
        .foreach(
            failure -> {
              final var warning =
                  FeelEvaluationWarning.of(
                      failure.failureType().toString(), failure.failureMessage());
              warnings.add(warning);
              return null;
            });
    return warnings;
  }