question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it possible to detect the difference between 0 instance candidates or >1 instance candidates from Instantiator.

See original GitHub issue

When Instantiator is used in Spring or CDI with an abstract target type, then an instance will be returned if there’s exactly one available bean type that implements that type. This is used in Collaboration Engine to allow the application developer to publish custom configuration for Collaboration Engine as a bean, without including any code in Collaboration Engine that would directly depend on Spring or CDI.

Since the configuration type itself is abstract, Instantiator.getOrCreate will fail if no bean is available (or if not using a DI container) or if there are multiple candidate beans. We would like to see the difference between those two cases: no bean probably means that the developer isn’t even trying to define configuration as a bean and should thus not be reported as a problem whereas the presence of multiple candidate beans is most likely a mistake in the application and it would be very useful if Collaboration Engine could let the developer know which beans are causing the conflict.

I can see two different ways of implementing this:

  1. getOrCreate could be enhanced to use a custom exception type that explicitly gives information to this kind of information
  2. Introduce a new method in Instantiator that is designed specifically for this purpose. The method could return a collection of candidates where each candidate would have some kind of identifier (String and/or Class) as well as a callback to actually create a specific instance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
plekucommented, Jan 25, 2021

Closing as a duplicate of #9756 as we’re not going to likely do much specifically for instantiators anymore just for Flow 2.x and this is not a blocker but an improvement for collaboration engine.

0reactions
Legiothcommented, Jan 15, 2021

This tickets targets all the Vaadin versions that we want Collaboration Engine to support, i.e. the latest Vaadin 14 and the latest non-LTS release train.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In constructor, candidate expects 1 argument, 0 provided
A simple and safe way to do that is to use a std::vector to hold the instances. class cat { private: int height;...
Read more >
Overload resolution - cppreference.com
If these steps produce more than one candidate function, then overload resolution is performed to select the function that will actually be ...
Read more >
Lab 8: Developing an Instantiable Class: Candidates
We say that each string object is an instance of the String class. Each instance has some data, which is stored in instance...
Read more >
Programming Example: Card, Hand, Deck
This gives use us two candidates for instance methods in a Deck class: shuffle() and dealCard(). Cards can be added to and removed...
Read more >
4.3 Dependencies - Spring
The basic principle behind Dependency Injection (DI) is that objects define their dependencies (that is to say the other objects they work with)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found