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

A few Minecraft servers display "Pinging..." followed by "Can't connect to server" on startup or when refreshed the multiplayer servers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 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
    • Fix Version/s: None
    • Environment:

      Windows 10 Pro, Java 1.8.0_151

    • Confirmation Status:
      Confirmed

      Description

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

        Attachments

        1. After.PNG
          After.PNG
          196 kB
        2. Before.PNG
          Before.PNG
          196 kB
        3. MC-125762.png
          MC-125762.png
          97 kB

          Issue Links

            Activity

              People

              • Assignee:
                dinnerbone [Mojang] Nathan Adams
                Reporter:
                PluginerTR Muhammet Kurt
              • Votes:
                12 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: