mojira.dev
MC-125762

Sometimes a few Minecraft servers display "Pinging..." followed by "Can't connect to server" in multiplayer server list

The bug

A few Minecraft servers display "Pinging..." followed by "Can't connect to server", occasionally. This appears to happen when opening the multiplayer/server list for the first time or after the minecraft client startup or when refreshed the multiplayer server lists.

Code analysis

It appears that most parts of the code analysis of MC-73207 apply again. There has been some refactoring (LazyLoadBase uses a Supplier now) which likely replaced the fix by accident.

The following class might be a better replacement for or addition to the LazyLoadBase class. The only restriction is that the factory should be thread-safe.

public class ThreadSafeLazySupplier<T> implements Supplier<T> {
    private final Supplier<T> factory;
    private final Object valueCreationMonitor;
    private volatile boolean hasValue;
    private volatile T value;
    
    public ThreadSafeLazySupplier(final Supplier<T> factory) {
        this.factory = factory;
        valueCreationMonitor = new Object();
        hasValue = false;
    }
    
    @Override
    public T get() {
        if (!hasValue) {
            synchronized(valueCreationMonitor) {
                if (!hasValue) {
                    value = factory.get();
                    hasValue = true;
                }
            }
        }
        
        return value;
    }
}

Linked issues

Attachments

Comments

bemoty

Cannot reproduce.

migrated

This is happening on startup of the game and occasionally.
> Try to add 5-6 server lists on your multiplayer menu and restart your game.
> Click to multiplayer
> if all servers is dislay online (if server is online) try again.

Try it a few times.

Otherwise this error it is from me.

migrated

The same problem occasionally occurs when refresh the server list.

migrated

I changed the title and the description. Because this problem is happen when refreshed the multiplayer server lists, too.

migrated

Happens in 1.12.2

migrated

@@unknown, in 1.12.2 this bug is exist but it's relates to MC-73207 and it's fixed in 1.13 snapshots.

migrated

Confirmed for 1.13.1, see

[media]
migrated

When I tried to click "Multiplayer" the server lists they will load very very slow. @[Mojang] Nathan Adams sorry but you need to fix this bug because lots of peoples are playing on multiplayer servers.

[Mod] markderickson

I can confirm in 21w07a and 1.16.5.

Tokelauan

1.17.1

migrated

(Unassigned)

Confirmed

Platform

Normal

UI

multiplayer, server-list

Minecraft 18w07c, Minecraft 18w08a, Minecraft 18w08b, Minecraft 18w09a, Minecraft 18w10c, ..., 19w36a, 19w37a, 1.16.5, 21w07a, 1.17.1

Retrieved