-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
getServersCopy() - NoSuchElementException #645
Comments
Something mutated the map while you where tryna create a copy of it seemingly |
How to avoid this? Is there a thread safe way modifying or cloning it? |
modifying the servers list is best done with the remove/add methods on the ProxyServer class, we already lock the collection in many cases but there is a limitation due to getServers itself returning a mutable list, part of the ideal setup would be to make this immutable, but, shamefully plugins get in the way of that, but, I question if the better alternative might be to override the relevant methods to direct calls to remove, etc, to the synchronized methods for this, but it is pretty gross |
Found them in the Configuration class, thanks. They synchronize on the serversLock object. Is this a feature from Waterfall, as i can't find this in BungeeCord itself? What is the reason for using troves tmap in the first place? Why not use a ConcurrentHashMap, which would fix most if not all of the concurrency issues? |
@Sneakometer The idea is probably that for most servers the server map is not changing, that's probably why it is using a fast map and manual synchronization |
Sadly, the broken BungeeCord API in question can't be fixed. If a plugin only uses the Waterfall methods, then everything will work, but CloudNet presumably needs to support upstream BungeeCord too, thus you get the issue. I'm going to sound like a broken record, but that's just one reason why @electronicboy encouraged me to go on my own instead. |
I'm not a java expert, but i can't believe that troves map is that much faster for those few entries (<100) in the servers map.
I already thought about switching to velocity at some point, but it requires quite a lot of hassle for me adding the support to all of my self made plugins. Some of them (at my fault) not using any abstraction to bungeecord at all. I was fine with bungeecord before using cloudnet for years, so i'm kinda hoping there is another solution to this :/ |
There really isn't, unless we break BungeeCord API compatibility. And at that point, you might as well just use Velocity. |
using a CHM as-is is not viable as we'd need to override a good chunk of its functionality in order to work properly |
You could ask CloudNet to use Waterfall's functions if they're found. |
So after years this issue still persists, even with the suggested fix by cloudnet in place. for (ServerInfo server : ProxyServer.getInstance()
.getServersCopy()
.values()) {
server.sendData("abc", data);
} Only temporary "fix" is to restart the proxy. |
This is likely a won't fix as the underlying issue is generally the unsafe collection that upstream has decided to use here |
Hey, i'm developing for Waterfall and need to retrieve the server list every now and then.
I'm using the
getServersCopy()
method provided by Waterfall in the ProxyServer instance, as the other one is marked as deprecated.However, i started to notice some weird behaviour lately, throwing the following exception everytime the getServersCopy() method is called:
Restarting the proxy fixed this for some time. The issue will however come back after some hours to a few days.
I'm also using the Cloudnet v3.4 orchestration to dynamically create servers at runtime. First i suspected the problem there, but a developer told me it's not caused by cloudnet.
I'm running the build from @Janmm14 (#609) for a while but only recently noticed this error. So i thought it's unlikely to be related to the dos mitigations.
Java 8
Debian 10
I'm not sure how to reproduce this other than just lettings the proxy run for a while.
I am willing to investigate furthe,r but i'm kinda out of ideas now.
//Edit the code that triggers the exception is:
The text was updated successfully, but these errors were encountered: