Skip to content

Make ComponentFinder.run() not fail on empty Set<DiscoveredComponent> #437

@ErikBfromB

Description

@ErikBfromB

Description

Hi everyone, first of all I want to mention that I really like and appreciate Structurizr and OS community work!

The ComponentFinder is truly convenient and helpful piece of software. However, when trying to find all component inside a provided Container with a specific ComponentFinderStrategy, which in turn does not return any DiscoveredComponent, the entire run() process stops with a RuntimeException.

ComponentFinder.run()

for (ComponentFinderStrategy componentFinderStrategy : componentFinderStrategies) {
    Set<DiscoveredComponent> set = componentFinderStrategy.run(typeRepository);
    if (set.isEmpty()) {
        throw new RuntimeException("No components were found by " + componentFinderStrategy);
    }
    discoveredComponents.addAll(set);
}

The resulting problem for a ComponentFinder implementation is, that all subsequently added strategies will be ignored.
Potentially this leads to incomplete "scanning" results. The current workaround is to create one ComponentFinderBuilder per ComponentFinderStrategy and wrap it with a catch clause to "ignore" or log the RuntimeException in order to proceed to the next ComponentFinderStrategy for the current Container.

Priority

Low (I have no budget and there's no rush - please add this feature for free)

More information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions