Skip to content

ChangeUnits containing Unnamed Variables (JEP443) are not found by Mongock.Β #69

@florian-gehring

Description

@florian-gehring

Description

ChangeUnits that contain unnamed variables (the "_" placeholder) anywhere in them, are not found or executed by Mongock. Replacing the placeholder with a named (and unused) variable will result in the ChangeUnit being found again.

PRIORITY

NORMAL / Not Sure

Version and environment

Mongock

  • Mongock version: COMMUNITY version[5.3.4]
  • Modules involved: springboot, MongoDB
  • How Mongock is used: annotation approach

Environment

  • Framework and libraries versions. Especially those that affect directly to Mongock:
    • Spring Boot Version: 3.1.4
  • Infrastructure: Kubernetes, Docker
  • Importing the mongock-bom dependency
  • Java Language Level 21 (Preview Features Enabled)

Steps to Reproduce

  1. Create a ChangeUnit that uses a Lambda Function with an unnamed variable, e.g. .map(document -> (AggregationOperation) _ -> document) somewhere in a stream.
  2. Start the application as normal

Behaviour

Expected behavior: The ChangeUnit gets executed
Actual behavior: Mongock does not find the ChangeUnit.

How often the bug happens: Every time.

Additional context

The reflection library Mongock uses apparently can't return classes containing these features.
In ChangeLogServiceBase.java:163 the ChangeUnit class is present in the Object constructed by new Reflections(changeLogsBasePackageList) but the getTypesAnnotatedWith(ChangeUnit.class) returns an empty list, if the "_"-Placeholder is used anywhere in the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions