Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
florian-gehring opened this issue Oct 24, 2023 · 7 comments

Comments

@florian-gehring
Copy link

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.

@spalberg
Copy link

We recently upgraded to java 21 with preview features enabled too and could not make sense of some changeunits not being picked up by mongock until reading your issue. We confirmed this issue with our codebase!

@dieppa
Copy link
Member

dieppa commented Oct 25, 2023

@florian-gehring we'll take a look at this, but for the time being, as workaround, is it enough if you don't use "_"?

@dieppa
Copy link
Member

dieppa commented Oct 25, 2023

@spalberg this is not the same problem. Please see this issue.

@spalberg
Copy link

@dieppa it's exactly the same issue as described here. When a changeunit uses the unnamed variable feature it is completely overlooked by mongock when picking up the changeunits via reflection. Not using the unnamed variable fixes that.

@dieppa
Copy link
Member

dieppa commented Oct 31, 2023

I am not familiar with that feature. We'll look at it as soon as possible.

In the meanwhile, yiu are welcome to raise a PR if you feel so.

@florian-gehring
Copy link
Author

florian-gehring commented Nov 1, 2023

@dieppa Hello, thank you for your comment. Yes, we've commited to not using "_" so the workaround is perfectly fine. This issue is less of a "PLEASE FIX" and more of a "Just FYI". It's a preview feature after all.

@dieppa
Copy link
Member

dieppa commented Nov 1, 2023

Thanks @florian-gehring for letting us know. We have a lot of new exciting things for the upcoming major release, hopefully we can add these nicr to have to it, so we are more up to date with modern java featured

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants