Skip to content

Factory.create should include ServiceLocator Name #681

Open
@buko

Description

@buko

Currently if Factory#create throws an exception the result is a stack trace that includes no information about the ServiceLocator:

Exception in thread "main" MultiException stack 1 of 3
java.lang.RuntimeException: test!!!
...
	at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:129)
	at org.jvnet.hk2.internal.AutoActiveDescriptor.create(AutoActiveDescriptor.java:148)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:458)
...
MultiException stack 2 of 3
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of Foo errors were found
	at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:224)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:334)
	at org.jvnet.hk2.internal.AutoActiveDescriptor.create(AutoActiveDescriptor.java:148)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:458)

Similar to #491 when HK2 encounters an exception while resolving dependencies it really should include the name amd LocatorId of the ServiceLocator that failed. In applications that include a hierarchy of ServiceLocators this would allow such problems to be quickly tracked down to the source.

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