Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-125762

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 18w07c, Minecraft 18w08a, Minecraft 18w08b, Minecraft 18w09a, Minecraft 18w10c, Minecraft 18w10d, Minecraft 18w11a, Minecraft 18w21a, Minecraft 18w21b, Minecraft 18w22a, Minecraft 18w22b, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre6, Minecraft 1.13-pre7, Minecraft 1.13-pre8, Minecraft 1.13-pre9, Minecraft 1.13-pre10, Minecraft 1.13, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w45a, Minecraft 18w46a, Minecraft 19w08b, Minecraft 19w09a, Minecraft 19w14b, Minecraft 1.14.2, Minecraft 1.14.3 Pre-Release 2, Minecraft 1.14.3 Pre-Release 3, 1.14.4, 19w35a, 19w36a, 19w37a, 1.16.5, 21w07a, 1.17.1
    • Windows 10 Pro, Java 1.8.0_151
    • Confirmed
    • UI
    • Normal
    • Platform

      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;
          }
      }
      

        1. Before.PNG
          Before.PNG
          196 kB
        2. After.PNG
          After.PNG
          196 kB
        3. MC-125762.png
          MC-125762.png
          97 kB
        4. Ekran Alıntısı.PNG
          Ekran Alıntısı.PNG
          148 kB
        5. Ekran Alıntısı 1.PNG
          Ekran Alıntısı 1.PNG
          163 kB
        6. MC-125762-1.png
          MC-125762-1.png
          141 kB

            Unassigned Unassigned
            PluginerTR Muhammet Kurt
            Votes:
            22 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              CHK: