Skip to content

Commit 07ab962

Browse files
committed
[MNG-6765] tycho pom-less builds fails with 3.6.2
1 parent eca4905 commit 07ab962

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,31 @@
3535
import org.eclipse.sisu.Typed;
3636

3737
/**
38-
* DefaultModelProcessor
38+
*
39+
* Note: uses @Typed to limit the types it is available for injection to just ModelProcessor.
40+
*
41+
* This is because the ModelProcessor interface extends ModelLocator and ModelReader. If we
42+
* made this component available under all its interfaces then it could end up being injected
43+
* into itself leading to a stack overflow.
44+
*
45+
* A side-effect of using @Typed is that it translates to explicit bindings in the container.
46+
* So instead of binding the component under a 'wildcard' key it is now bound with an explicit
47+
* key. Since this is a default component this will be a plain binding of ModelProcessor to
48+
* this implementation type, ie. no hint/name.
49+
*
50+
* This leads to a second side-effect in that any @Inject request for just ModelProcessor in
51+
* the same injector is immediately matched to this explicit binding, which means extensions
52+
* cannot override this binding. This is because the lookup is always short-circuited in this
53+
* specific situation (plain @Inject request, and plain explicit binding for the same type.)
54+
*
55+
* The simplest solution is to use a custom @Named here so it isn't bound under the plain key.
56+
* This is only necessary for default components using @Typed that want to support overriding.
57+
*
58+
* As a non-default component this now gets a negative priority relative to other implementations
59+
* of the same interface. Since we want to allow overriding this doesn't matter in this case.
60+
* (if it did we could add @Priority of 0 to match the priority given to default components.)
3961
*/
40-
@Named
62+
@Named( "core-default" )
4163
@Singleton
4264
@Typed( ModelProcessor.class )
4365
public class DefaultModelProcessor

0 commit comments

Comments
 (0)