I noticed a bug in openfire’s HybridUserProvider today. The code below results in “userproviders” always containing null values.
Since this breaks the provider, I cant imagine it always worked this way. It looks like a regression introduced by a refactoring. Its a good example of where unit tests repay the high cost of their creation.
public class HybridUserProvider implements UserProvider {
How would HybridUserProvider be set in this fashion, e.g. from a user’s perspective? I don’t understand what circumstances would cause this bug to be manifested.
userproviders[] is initialized with null values. That’s just fine, but I assume that one would like to add assign usefull values to it at the end of the constructor
public HybridUserProvider() { ...;
userproviders = {primaryProvider, secondaryProvider, tertiaryProvider};
}
...
for (UserProvider provider : userproviders) {
So the for loop may work much better.
Otherwise it is a private read-only object and one should make it final, just like this (while I think that this was not the intention):
private final UserProvider[] userproviders = {null, null, null};