Skip to content

fix: replace Janino EvaluatorFilter expression with a native evaluator - #81

Merged
Cervator merged 3 commits into
developfrom
fix/logback-1.6-evaluator-migration
Jul 29, 2026
Merged

fix: replace Janino EvaluatorFilter expression with a native evaluator#81
Cervator merged 3 commits into
developfrom
fix/logback-1.6-evaluator-migration

Conversation

@soloturn

@soloturn soloturn commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

AI-assisted change proposal. Filed by agent driven by @soloturn via GDD.

Summary

  • Terasology is bumping Logback from 1.4.14 to 1.6.0 (the current actively-developed release; 1.4.x is EOL). default-logback.xml's EvaluatorFilter used a Janino-compiled expression (reflectionsEmpty.matches(message)) to suppress Reflections' noisy "given scan urls are empty" warning - JaninoEventEvaluator was actually removed back in Logback 1.5.13, well before this jump.
  • Verified empirically: under both 1.5.13+ and 1.6.0, this configuration silently falls back to a no-op StubEventEvaluator instead of failing loudly - both a matching and a non-matching log line got through in a test run, i.e. the DENY never fired. The filter would have quietly stopped working rather than crashing, so this was easy to miss.
  • Replaced with ReflectionsEmptyEvaluator, a small native EventEvaluator<ILoggingEvent> implementation doing the same regex check in plain Java (Logback's suggested migration path for removed Janino expressions).
  • Verified in isolation against the real logback-classic:1.6.0 jar that the DENY correctly fires for a matching message and lets a non-matching one through, with no evaluator warnings at startup (the old config printed a "stub for JaninoEventEvaluator" warning on every run).
  • The runtimeOnly Janino dependency this filter needed (terasology-module.gradle.kts, in the main Terasology repo) is no longer required and is being removed there as part of the companion PR.

Test plan

  • Standalone repro: config with the new evaluator loads cleanly under logback-classic:1.6.0, correctly denies a message matching "given scan urls are empty" and allows a non-matching one through, no startup warnings.
  • Run a module test suite using ModuleTestingEnvironment and confirm the Reflections scan-empty warning is still suppressed in test output.

Related

Summary by CodeRabbit

  • Bug Fixes
    • Improved logging behavior by suppressing specific “given scan URLs are empty” warnings.
    • Ensured only the matching warning is filtered, while all other log messages remain unchanged.
  • New Features
    • Added a custom Logback evaluator to detect the warning reliably and handle it consistently.

default-logback.xml's EvaluatorFilter used a Janino-compiled expression
(reflectionsEmpty.matches(message)) to suppress Reflections' noisy "given
scan urls are empty" warning. JaninoEventEvaluator was removed in Logback
1.5.13, and Terasology is bumping to 1.6.0 - under either version this
expression silently falls back to a no-op StubEventEvaluator (confirmed
empirically: both the matching and non-matching log lines got through,
i.e. the DENY never fired), so the filter would have quietly stopped
working instead of failing loudly.

Replaced with ReflectionsEmptyEvaluator, a small native
EventEvaluator<ILoggingEvent> implementation doing the same regex check in
plain Java. Verified in isolation against the real logback-classic 1.6.0
jar that the DENY correctly fires for a matching message and lets a
non-matching one through, with no evaluator warnings at startup (the old
config printed a "stub for JaninoEventEvaluator" warning on every run).

The runtimeOnly Janino dependency this filter needed
(terasology-module.gradle.kts, MovingBlocks/Terasology) is no longer
required and is being removed there as part of the same change.
@soloturn soloturn added the Type: Bug Issues reporting and PRs fixing problems label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b635330-2923-4dd9-9305-f3af1652712e

📥 Commits

Reviewing files that changed from the base of the PR and between 44fad44 and 09cad03.

📒 Files selected for processing (1)
  • src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java

📝 Walkthrough

Walkthrough

Adds a custom Logback evaluator for detecting empty reflections scan warnings and replaces the inline evaluator configuration with the new class while preserving the existing filter outcomes.

Changes

Reflections warning filtering

Layer / File(s) Summary
Evaluator implementation and Logback wiring
src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java, src/main/resources/org/terasology/moduletestingenvironment/default-logback.xml
The new evaluator matches the empty-scan warning, exposes lifecycle and name methods, and is referenced by the existing EvaluatorFilter configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: cervator, benjaminamos

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing the Janino-based Logback evaluator expression with a native evaluator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/logback-1.6-evaluator-migration

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java`:
- Around line 26-27: Update ReflectionsEmptyEvaluator.evaluate to match
REFLECTIONS_EMPTY against event.getMessage() instead of
event.getFormattedMessage(), preserving the evaluator’s behavior for
parameterized logging messages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: af43ebed-12aa-46a2-b9dd-b47fa91986a8

📥 Commits

Reviewing files that changed from the base of the PR and between e05c195 and 44fad44.

📒 Files selected for processing (2)
  • src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java
  • src/main/resources/org/terasology/moduletestingenvironment/default-logback.xml

@agent-refr

Copy link
Copy Markdown

Tested locally alongside MovingBlocks/Terasology#5343 on an Omega workspace. Looks good — the evaluator implements EventEvaluator + LifeCycle correctly and the XML keeps OnMatch DENY / OnMismatch NEUTRAL unchanged.

A/B on :modules:ModuleTestingEnvironment:test, both under Logback 1.6.0:

  • Old config: |-WARN in StubEventEvaluator - This class is a stub for JaninoEventEvaluator which was removed in logback, plus the migration hints. Confirms the silent degradation this PR describes.
  • This branch: no evaluator warnings, no Logback status output at all, suite passes.

One caveat on the unchecked test-plan item. I could not verify the DENY actually fires, because Reflections never emits "given scan urls are empty" in these runs — the only occurrences of that logger in the output are Logback setting its level. So absence of the message proves nothing either way; your isolated repro remains the real evidence for the filter behaviour.

Also worth rewording that item: "ModuleTestingEnvironment-based module tests" is ambiguous now that MTE exists twice. Modules using the engine's @IntegrationEnvironment never load default-logback.xml — only the legacy org.terasology.moduletestingenvironment.MTEExtension does, in setupLogging(). No Omega module uses that path; this repo's own suite is the only consumer, so it's the only place the change is observable.

Merge order: after #5343 — the evaluator needs the Logback 1.6.0 that terasology-module.gradle.kts pulls in there.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ModuleTestingEnvironment’s default Logback configuration to keep suppressing Reflections’ “given scan urls are empty” warning after Logback removed Janino-based evaluators, by replacing the removed Janino expression with a native Java EventEvaluator.

Changes:

  • Replaced the Janino EvaluatorFilter expression in default-logback.xml with a custom evaluator class reference.
  • Added ReflectionsEmptyEvaluator, a Java EventEvaluator<ILoggingEvent> that matches the Reflections “scan urls are empty” warning text.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/resources/org/terasology/moduletestingenvironment/default-logback.xml Switches the EvaluatorFilter to use a native evaluator class instead of a Janino expression.
src/main/java/org/terasology/moduletestingenvironment/logging/ReflectionsEmptyEvaluator.java Implements the custom Logback evaluator used by the XML configuration to deny matching Reflections warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +28
@Override
public boolean evaluate(ILoggingEvent event) throws EvaluationException {
return REFLECTIONS_EMPTY.matcher(event.getFormattedMessage()).find();
}
Comment on lines +18 to +28
public class ReflectionsEmptyEvaluator extends ContextAwareBase implements EventEvaluator<ILoggingEvent>, LifeCycle {

private static final Pattern REFLECTIONS_EMPTY = Pattern.compile("given scan urls are empty");

private String name;
private boolean started;

@Override
public boolean evaluate(ILoggingEvent event) throws EvaluationException {
return REFLECTIONS_EMPTY.matcher(event.getFormattedMessage()).find();
}
Matches the `message` binding the Janino expression used, and avoids denying
events whose arguments happen to contain the phrase. Null-guarded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@Cervator Cervator left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent through usual counter-agent review process and added a little tweak. Merging after the engine PR finished (gotta run, not waiting the 10 minutes for Jenkins to say it is still all-ok)

@Cervator
Cervator merged commit c93a00f into develop Jul 29, 2026
2 of 5 checks passed
@Cervator
Cervator deleted the fix/logback-1.6-evaluator-migration branch July 29, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Issues reporting and PRs fixing problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants