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

Expression Language - Getting bean which has env in path #11410

Open
hrothwell opened this issue Dec 4, 2024 · 3 comments
Open

Expression Language - Getting bean which has env in path #11410

hrothwell opened this issue Dec 4, 2024 · 3 comments

Comments

@hrothwell
Copy link
Contributor

hrothwell commented Dec 4, 2024

Expected Behavior

When using expression langauge coupled with bean ctx retrieval, I expect to be able to access beans such as io.micronaut.context.env.Environment

Actual Behaviour

The project fails to compile stating:
[ksp] /path/to/bad/file/File.kt: Failed to parse evaluated expression [#{ ctx[io.micronaut.context.env.Environment].activeNames.contains('test') }]. Cause: Unexpected token: env. Expected: 'IDENTIFIER'

Steps To Reproduce

  1. try getting an Environment bean from ctx in an expression on a method
  2. try to compile the project

Environment Information

  • tested on JDK 17
  • My test branch is on Microanut 4.3.2 and I've also tested 4.6.x, assuming this happens across multiple versions

Example Application

https://github.com/hrothwell/micronaut-demo/tree/expression-language-environment-bean-issue

Specific class

Version

4.3.2

@graemerocher
Copy link
Contributor

does ctx.environment.activeNames work?

@hrothwell
Copy link
Contributor Author

ctx.environment.activeNames

"#{ ctx.environment.activeNames.activeNames.contains('test') }" does not work also for a similar reasoning:

Failed to parse evaluated expression [#{ ctx.environment.activeNames.activeNames.contains('test') }]. Cause: Unexpected token: .. Expected: 'L_SQUARE'

@hrothwell
Copy link
Contributor Author

FWIW I am taking a deeper look into the SingleEvaluatedExpressionParser and how it works, my first guess is that there is only one branch/means of processing after matching a specific token for ctx and env

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

2 participants