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

ParametersTest.testCustomParameters fails for test-guice-version=5.0.1 #35

Closed
mcculls opened this issue Oct 29, 2021 · 3 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@mcculls
Copy link
Contributor

mcculls commented Oct 29, 2021

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.eclipse.sisu.wire.ParametersTest
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.659 s <<< FAILURE! - in org.eclipse.sisu.wire.ParametersTest
[ERROR] org.eclipse.sisu.wire.ParametersTest.testCustomParameters  Time elapsed: 0.143 s  <<< ERROR!
com.google.inject.CreationException: 
Unable to create injector, see the following errors:

1) An exception was caught and reported. Message: This Provider cannot be used until the Injector has been created.
  at [unknown source]

2) [Guice/MissingImplementation]: No implementation for String[] annotated with @Parameters() was bound.

Requested by:
1  : ParametersTest.arguments(ParametersTest.java:26)
      \_ for field arguments
     at ParametersTest$2.configure(ParametersTest.java:60)
      \_ installed by: WireModule -> ParametersTest$2

Learn more:
  https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION

3) [Guice/MissingImplementation]: No implementation for Map<String, String> annotated with @Parameters() was bound.

Requested by:
1  : ParametersTest.properties(ParametersTest.java:26)
      \_ for field properties
     at ParametersTest$2.configure(ParametersTest.java:60)
      \_ installed by: WireModule -> ParametersTest$2

Learn more:
  https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION

3 errors

======================
Full classname legend:
======================
Parameters:       "org.eclipse.sisu.Parameters"
ParametersTest:   "org.eclipse.sisu.wire.ParametersTest"
ParametersTest$2: "org.eclipse.sisu.wire.ParametersTest$2"
WireModule:       "org.eclipse.sisu.wire.WireModule"
========================
End of classname legend:
========================

	at org.eclipse.sisu.wire.ParametersTest.testCustomParameters(ParametersTest.java:55)
Caused by: java.lang.IllegalStateException: This Provider cannot be used until the Injector has been created.
	at org.eclipse.sisu.wire.ParametersTest.testCustomParameters(ParametersTest.java:55)
@mcculls mcculls changed the title ParametersTest.testCustomParameters fails with -Dtest-guice-version=5.0.1 ParametersTest.testCustomParameters fails when using -Dtest-guice-version=5.0.1 Oct 29, 2021
@mcculls mcculls changed the title ParametersTest.testCustomParameters fails when using -Dtest-guice-version=5.0.1 ParametersTest.testCustomParameters fails for test-guice-version=5.0.1 Oct 29, 2021
@mcculls
Copy link
Contributor Author

mcculls commented Oct 29, 2021

This also happens for test-guice-version=4.2.0

@mcculls
Copy link
Contributor Author

mcculls commented Oct 29, 2021

The underlying issue is in ElementAnalyzer.mergeParameters where it attempts to merge different sources of parameters into a single map or sequence. It assumes that @Provides bindings can be called immediately, which is true for the test when using Guice 4.1.0 or earlier but isn't true for Guice 4.2.0 or later.

The solution will be to do the merge lazily, caching the result to avoid having to merge it on every request.

@mcculls mcculls added the bug Something isn't working label Dec 31, 2021
@mcculls
Copy link
Contributor Author

mcculls commented Jan 3, 2022

Fixed by #41

@mcculls mcculls closed this as completed Jan 3, 2022
@mcculls mcculls added this to the 0.9.0.M1 milestone May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant