-
Notifications
You must be signed in to change notification settings - Fork 130
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
Ipbanlist fixes #75
Ipbanlist fixes #75
Conversation
…hich doesn't have to be non-static
…etter performance
looks good, some remarks:
sidenote: |
…nedIpsIfNeeded() method as per review comment
Hello Michael, thanks for the review :)
In order to reuse the Set that way, I think we need to clear and populate it somehow atomically, which I'm not sure how, because otherwise it will introduce a time window where isBanned() gets called while the Set is empty which sounds like some kind of vulnerability. Based on that, I guess using volatile this way is kind of reasonable
Agreed. Removed at a5417a5 |
you are right. This would require a temporary map and iterating through the concurrent map which causes also issues. My initial thought was to keep volatile but make the map immutable (swap on write), since its rarely updated but read in every request. But I don't know how the file is used in practice - so lets keep your solution.
awesome another thing: |
Even once per second seems a bit excessive. |
Removed Mockito from pom.xml at 15bf473 , I thought I would need it but it turned out I didn't for now. As for AssertJ, I'd like to keep it as it's much better than standard ones. |
@nuzayats thanks! I do like fluent interfaces too, just that i don't feel that it adds enough benefits in this particular case, to justify a new test dependency (just for one small junit test). |
LGTM |
For this one at least it adds some benefit I think for example:
The standard assertion APIs don't provide such a collection verification if I'm not mistaken. Also to me having a new test dependency is not such a big deal but is there something concerning about it? |
or if you prefer one line
Its far less problematic than a runtime dependency - i agree. Still, it has to pull its weight. Old projects tend to accumulate dependencies and removing them is always a little bit more difficult than adding new ones. More dependencies mean more maintenance time spent to keep them updated and detect abandoned projects to migrate away from. The red flags here are that this library is only used by a single (small) test, and it is also not convincing to me that it is really necessary for that test. However the impact is little (and it has no transitive dependencies), so if you really want it, I am ok to merge your changes. (thanks again for the contribution btw, esp also for adding a test case) |
Removed AssertJ at 9dca2da . But it sounds like I will have to stick with the basic or outdated assertion APIs in Roller development unless there is a chance to write substantial amount of new code and tests even though there is a much better assertion library available already today. The points you raised are valid but writing unit tests with fundamental |
thanks for understanding. I am not opposed to AssertJ, if we have extensive collection based tests in future we can still add it so we get some proper use out of it. But maybe not for two lines delta :) |
Fixes some concurrency issues in the IPBanList class:
There are also some minor code improvements suggested by IntelliJ