PaperMC / PaperMC/Waterfall

getServersCopy() - NoSuchElementException

Open
#645 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
752
Forks
307
Avg merge
15h 48m
Merged PRs (30d)
7

Description

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:

[21:43:23] [pool-10-thread-5/ERROR]: java.util.NoSuchElementException
[21:43:23] [pool-10-thread-5/ERROR]:     at gnu.trove.impl.hash.THashIterator.moveToNextIndex(THashIterator.java:139)
[21:43:23] [pool-10-thread-5/ERROR]:     at gnu.trove.impl.hash.THashIterator.next(THashIterator.java:91)
[21:43:23] [pool-10-thread-5/ERROR]:     at gnu.trove.map.hash.TCustomHashMap$MapBackedView.toArray(TCustomHashMap.java:729)
[21:43:23] [pool-10-thread-5/ERROR]:     at com.google.common.collect.Iterables.toArray(Iterables.java:295)
[21:43:23] [pool-10-thread-5/ERROR]:     at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:406)
[21:43:23] [pool-10-thread-5/ERROR]:     at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:391)
[21:43:23] [pool-10-thread-5/ERROR]:     at net.md_5.bungee.conf.Configuration.getServersCopy(Configuration.java:189)
[21:43:23] [pool-10-thread-5/ERROR]:     at net.md_5.bungee.BungeeCord.getServersCopy(BungeeCord.java:648)

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 (https://github.com/PaperMC/Waterfall/pull/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:

for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()) {
...
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Configuration.getServersCopy() at Configuration.java:189 and its caller BungeeCord.getServersCopy() at BungeeCord.java:648. Investigate the failure while server entries are created or removed dynamically, using the reported CloudNet setup as context. Done means repeated server-list retrieval no longer throws NoSuchElementException under runtime server changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.