MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

While loop created outside try block with a return statement - 1.16/1.15 ClientThread#run #73

Closed Cyborgmas closed 1 year ago

Cyborgmas commented 4 years ago
   public void run() {
      while(true) {
         try {
            if (!this.field_72619_a) {
               return;
            }

            BufferedInputStream bufferedinputstream = new BufferedInputStream(this.field_72659_h.getInputStream());
            int i = bufferedinputstream.read(this.field_72660_i, 0, 1460);
            if (10 <= i) {
               int j = 0;
               int k = RConUtils.func_72665_b(this.field_72660_i, 0, i);
               if (k != i - 4) {
                  return;
               }

               j = j + 4;
               int l = RConUtils.func_72665_b(this.field_72660_i, j, i);
               j = j + 4;
               int i1 = RConUtils.func_72662_b(this.field_72660_i, j);
               j = j + 4;
               switch(i1) {
               case 2:
                  if (this.field_72657_g) {
                     String s1 = RConUtils.func_72661_a(this.field_72660_i, j, i);

                     try {
                        this.func_72655_a(l, this.field_232651_i_.func_71252_i(s1));
                     } catch (Exception exception) {
                        this.func_72655_a(l, "Error executing: " + s1 + " (" + exception.getMessage() + ")");
                     }
                     continue;
                  }

                  this.func_72656_f();
                  continue;
               case 3:
                  String s = RConUtils.func_72661_a(this.field_72660_i, j, i);
                  int j1 = j + s.length();
                  if (!s.isEmpty() && s.equals(this.field_72658_j)) {
                     this.field_72657_g = true;
                     this.func_72654_a(l, 2, "");
                     continue;
                  }

                  this.field_72657_g = false;
                  this.func_72656_f();
                  continue;
               default:
                  this.func_72655_a(l, String.format("Unknown request %s", Integer.toHexString(i1)));
                  continue;
               }
            }
         } catch (SocketTimeoutException sockettimeoutexception) {
            return;
         } catch (IOException ioexception) {
            return;
         } catch (Exception exception1) {
            field_164005_h.error("Exception whilst parsing RCON input", (Throwable)exception1);
            return;
         } finally {
            this.func_72653_g();
            field_164005_h.info("Thread {} shutting down", (Object)this.field_164003_c);
            this.field_72619_a = false;
         }
         return;
      }
   }

The loop is created outside the try block and has a return statement immediately after it. It should be created inside the try block