-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scanner for name repository is problematic when constants values are not unique #31
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
@Test | ||
public void testDuplicateConstantEntry() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the test that should work after the improvements
I don't think there is a general solution for this problem - how shall we know which constant is the "right" one? Unless we want to work somehow with annotations (e.g. qualifiers) I think the best would be to force exactly one match or else throw. There could be another method which never throws but returns a Set of names. |
Yes, there isn't a clear option in my opinion. We anyway have to choose one, I think throwing is a good option since at least you get a nice error message, but then we have to restrict the packages to scan, because it will throw while scanning Java packages out of our control (this it exactly what was happening). |
Probably a solution could be to not throw when scanning, but keep the set in the repo. However, when querying we could have several methods (There one has to know what to expect and it is potentially a better moment to throw...). E.g. :
What would you think? |
Agree :) |
Found out when building on Travis with jdk9. If the package scan finds, e.g., 2 constants with the same value, the key of the internal map will be the same overriding one of them..
How could we improve this? This pull request is just for not forgetting about this :)