Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8175879

issue in if else condition

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      C:\Program Files\Java\jdk1.8.0_121\bin>java -version
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      windows 7 64 bit

      A DESCRIPTION OF THE PROBLEM :
      I have a function that should return false but instead was returning true. So I thought I had a bug in my code. So I put System.out.println in the code. The function then returned false. I then commented out the System.out.println statements. The function still worked fine. It returned false. I then removed the commented out System.println statements. Then the code returned true. So I then reinstalled jdk1.8.112. I tried it with and without the comments. It worked both ways. It worked as expected. So there is something odd about 121.

      REGRESSION. Last worked in version 8u112

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      This code does not work in 121. It returns a true but should return false. In 112 this code works and returns a false.
      public static boolean isSkinUsedInEmailOrMassmail(Skin skin)
      {
      if (skin == null || skin.getType() == null)
      {
      return false;
      }
      //
      if (skin.getType().indexOf("emailer") > -1 || skin.getType().indexOf("ecard") > -1 || skin.getType().indexOf("massmail") > -1)
      {
      if (adminFactory.getSkinUsedInEmail(skin) != null)
      {
      return true;
      }
      else if (adminFactory.getSkinUsedInMassmail(skin) != null)
      {
      return true;
      }
      else
      {
      return false;
      }
      }
      else
      {
      return false;
      }
      }

      When you change the above code to the below it works on 121.
      public static boolean isSkinUsedInEmailOrMassmail(Skin skin)
      {
      if (skin == null || skin.getType() == null)
      {
      return false;
      }
      //
      // System.out.println("1");
      if (skin.getType().indexOf("emailer") > -1 || skin.getType().indexOf("ecard") > -1 || skin.getType().indexOf("massmail") > -1)
      {
      // System.out.println("2");
      if (adminFactory.getSkinUsedInEmail(skin) != null)
      {
      // System.out.println("fail email");
      return true;
      }
      else if (adminFactory.getSkinUsedInMassmail(skin) != null)
      {
      // System.out.println("fail massmail");
      return true;
      }
      else
      {
      return false;
      }
      }
      else
      {
      return false;
      }
      }
      It also works in 121 if you uncomment the System.out lines like this:
      public static boolean isSkinUsedInEmailOrMassmail(Skin skin)
      {
      if (skin == null || skin.getType() == null)
      {
      return false;
      }
      //
      System.out.println("1");
      if (skin.getType().indexOf("emailer") > -1 || skin.getType().indexOf("ecard") > -1 || skin.getType().indexOf("massmail") > -1)
      {
      System.out.println("2");
      if (adminFactory.getSkinUsedInEmail(skin) != null)
      {
      System.out.println("fail email");
      return true;
      }
      else if (adminFactory.getSkinUsedInMassmail(skin) != null)
      {
      System.out.println("fail massmail");
      return true;
      }
      else
      {
      return false;
      }
      }
      else
      {
      return false;
      }
      }



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      I had to reinstall 112

            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: