I made a code review for BridgeTopologyDiscovery.
At the moment the code needs to be revisited and simplified.
Investigating some bugs I found that the SimpleConnection class that finds the links between two bridges is failing but with the provided information one can reasonable find the connection ports.
Also the code is too much complicate and need to be simplified.
The port search algorithm is simple and it seems that the code is not showing this simplicity.
Also there is no need to consider fail if only one port is found.
The improvements will be gradual, but the first step is to let this class found eventually one port on one of the bridge. This can be used to find the topology. And use this in the iteration.
In practice the search for bridge topology is done recursively starting from root.
Because of the spanning tree algorithm the bridge topology graph must be simple connected.
This means that there is only one path from a bridge to another.
Bridge are on layers juts down the root.
So The recursive algorithm starts from the root and go down to find the layer on which the bridge belongs.
In line of principle you can start investigating the position of a new bridge in topology at any layer. This will be a second proposition to try to find eventually the layer position of a bridge that is for some reason failing.