/* goodB2G() - use badsource and goodsink */
  private void goodB2G(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    int data;

    data = Integer.MIN_VALUE; /* Initialize data */

    /* POTENTIAL FLAW: Read data from a querystring using getParameter() */
    {
      String stringNumber = request.getParameter("name");

      try {
        data = Integer.parseInt(stringNumber.trim());
      } catch (NumberFormatException exceptNumberFormat) {
        IO.logger.log(
            Level.WARNING,
            "Number format exception reading data from parameter 'name'",
            exceptNumberFormat);
      }
    }

    /* FIX: Add a check to prevent an overflow from occurring */
    /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
    if ((data != Integer.MIN_VALUE)
        && (data != Long.MIN_VALUE)
        && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
      int result = (int) (data * data);
      IO.writeLine("result: " + result);
    } else {
      IO.writeLine("data value is too large to perform squaring.");
    }
  }
  /* goodB2G1() - use badsource and goodsink by changing second IO.staticReturnsTrue() to IO.staticReturnsFalse() */
  private void goodB2G1() throws Throwable {
    int data;
    if (IO.staticReturnsTrue()) {
      data = Integer.MIN_VALUE; /* Initialize data */
      /* retrieve the property */
      {
        Properties properties = new Properties();
        FileInputStream streamFileInput = null;
        try {
          streamFileInput = new FileInputStream("../common/config.properties");
          properties.load(streamFileInput);
          /* POTENTIAL FLAW: Read data from a .properties file */
          String stringNumber = properties.getProperty("data");
          if (stringNumber != null) // avoid NPD incidental warnings
          {
            try {
              data = Integer.parseInt(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* Close stream reading object */
          try {
            if (streamFileInput != null) {
              streamFileInput.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing FileInputStream", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0;
    }

    if (IO.staticReturnsFalse()) {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
      IO.writeLine("Benign, fixed string");
    } else {

      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
        int result = (int) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }
    }
  }
  /* goodB2G1() - use badsource and goodsink by changing second privateReturnsTrue() to privateReturnsFalse() */
  private void goodB2G1() throws Throwable {
    long data;
    if (privateReturnsTrue()) {
      /* POTENTIAL FLAW: Use the maximum size of the data type */
      data = Long.MAX_VALUE;
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0L;
    }

    if (privateReturnsFalse()) {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
      IO.writeLine("Benign, fixed string");
    } else {

      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Long.MAX_VALUE))) {
        long result = (long) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }
    }
  }
  /* goodB2G1() - use badsource and goodsink by changing second PRIVATE_STATIC_FINAL_FIVE==5 to PRIVATE_STATIC_FINAL_FIVE!=5 */
  private void goodB2G1() throws Throwable {
    short data;
    if (PRIVATE_STATIC_FINAL_FIVE == 5) {
      /* POTENTIAL FLAW: Use a random value */
      data =
          (short)
              ((new java.security.SecureRandom()).nextInt(1 + Short.MAX_VALUE - Short.MIN_VALUE)
                  + Short.MIN_VALUE);
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0;
    }

    if (PRIVATE_STATIC_FINAL_FIVE != 5) {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
      IO.writeLine("Benign, fixed string");
    } else {

      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Short.MAX_VALUE))) {
        short result = (short) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }
    }
  }
  private void goodB2GSink(byte data) throws Throwable {

    /* FIX: Add a check to prevent an overflow from occurring */
    /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
    if ((data != Integer.MIN_VALUE)
        && (data != Long.MIN_VALUE)
        && (Math.abs(data) <= (long) Math.sqrt(Byte.MAX_VALUE))) {
      byte result = (byte) (data * data);
      IO.writeLine("result: " + result);
    } else {
      IO.writeLine("data value is too large to perform squaring.");
    }
  }
  /* goodB2G() - use BadSource and GoodSink */
  public void goodB2GSink(HashMap<Integer, Long> dataHashMap) throws Throwable {
    long data = dataHashMap.get(2);

    /* FIX: Add a check to prevent an overflow from occurring */
    /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
    if ((data != Integer.MIN_VALUE)
        && (data != Long.MIN_VALUE)
        && (Math.abs(data) <= (long) Math.sqrt(Long.MAX_VALUE))) {
      long result = (long) (data * data);
      IO.writeLine("result: " + result);
    } else {
      IO.writeLine("data value is too large to perform squaring.");
    }
  }
  /* goodB2G() - use badsource and goodsink */
  private void goodB2G() throws Throwable {
    int data = (new CWE190_Integer_Overflow__int_Environment_square_61b()).goodB2GSource();

    /* FIX: Add a check to prevent an overflow from occurring */
    /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
    if ((data != Integer.MIN_VALUE)
        && (data != Long.MIN_VALUE)
        && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
      int result = (int) (data * data);
      IO.writeLine("result: " + result);
    } else {
      IO.writeLine("data value is too large to perform squaring.");
    }
  }
  /* goodB2G() - use badsource and goodsink */
  public void goodB2GSink(int data, HttpServletRequest request, HttpServletResponse response)
      throws Throwable {

    /* FIX: Add a check to prevent an overflow from occurring */
    /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
    if ((data != Integer.MIN_VALUE)
        && (data != Long.MIN_VALUE)
        && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
      int result = (int) (data * data);
      IO.writeLine("result: " + result);
    } else {
      IO.writeLine("data value is too large to perform squaring.");
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    float data;
    if (IO.staticReturnsTrue()) {
      data = -1.0f; /* Initialize data */
      /* get system property user.home */
      /* POTENTIAL FLAW: Read data from a system property */
      {
        String stringNumber = System.getProperty("user.home");
        if (stringNumber != null) {
          try {
            data = Float.parseFloat(stringNumber.trim());
          } catch (NumberFormatException exceptNumberFormat) {
            IO.logger.log(
                Level.WARNING,
                "Number format exception parsing data from string",
                exceptNumberFormat);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (IO.staticReturnsTrue()) {
      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }
  /* goodB2G() - use BadSource and GoodSink */
  public void goodB2GSink(byte[] dataSerialized) throws Throwable {
    /* unserialize data */
    ByteArrayInputStream streamByteArrayInput = null;
    ObjectInputStream streamObjectInput = null;

    try {
      streamByteArrayInput = new ByteArrayInputStream(dataSerialized);
      streamObjectInput = new ObjectInputStream(streamByteArrayInput);
      int data = (Integer) streamObjectInput.readObject();

      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
        int result = (int) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }

    } catch (IOException exceptIO) {
      IO.logger.log(Level.WARNING, "IOException in deserialization", exceptIO);
    } catch (ClassNotFoundException exceptClassNotFound) {
      IO.logger.log(
          Level.WARNING, "ClassNotFoundException in deserialization", exceptClassNotFound);
    } finally {
      /* clean up stream reading objects */
      try {
        if (streamObjectInput != null) {
          streamObjectInput.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing ObjectInputStream", exceptIO);
      }

      try {
        if (streamByteArrayInput != null) {
          streamByteArrayInput.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing ByteArrayInputStream", exceptIO);
      }
    }
  }
  /* goodB2G() - use badsource and goodsink */
  public void goodB2GSink(float data) throws Throwable {

    /* FIX: Check for value of or near zero before modulo */
    if (Math.abs(data) > 0.000001) {
      int result = (int) (100.0 % data);
      IO.writeLine(result);
    } else {
      IO.writeLine("This would result in a modulo by zero");
    }
  }
  private void goodB2GSink(float data) throws Throwable {

    /* FIX: Check for value of or near zero before dividing */
    if (Math.abs(data) > 0.000001) {
      int result = (int) (100.0 / data);
      IO.writeLine(result);
    } else {
      IO.writeLine("This would result in a divide by zero");
    }
  }
  public void bad() throws Throwable {
    float data;
    if (IO.staticReturnsTrueOrFalse()) {
      data = -1.0f; /* Initialize data */
      /* retrieve the property */
      Properties properties = new Properties();
      FileInputStream streamFileInput = null;
      try {
        streamFileInput = new FileInputStream("../common/config.properties");
        properties.load(streamFileInput);
        /* POTENTIAL FLAW: Read data from a .properties file */
        String stringNumber = properties.getProperty("data");
        if (stringNumber != null) {
          try {
            data = Float.parseFloat(stringNumber.trim());
          } catch (NumberFormatException exceptNumberFormat) {
            IO.logger.log(
                Level.WARNING,
                "Number format exception parsing data from string",
                exceptNumberFormat);
          }
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
      } finally {
        /* Close stream reading object */
        try {
          if (streamFileInput != null) {
            streamFileInput.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing FileInputStream", exceptIO);
        }
      }
    } else {

      /* FIX: Use a hardcoded number that won't a divide by zero */
      data = 2.0f;
    }

    if (IO.staticReturnsTrueOrFalse()) {
      /* POTENTIAL FLAW: Possibly modulo by zero */
      int result = (int) (100.0 % data);
      IO.writeLine(result);
    } else {

      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }
  /* goodB2G() - use badsource and goodsink */
  private void goodB2G() throws Throwable {
    float data = (new CWE369_Divide_by_Zero__float_zero_divide_61b()).goodB2GSource();

    /* FIX: Check for value of or near zero before dividing */
    if (Math.abs(data) > 0.000001) {
      int result = (int) (100.0 / data);
      IO.writeLine(result);
    } else {
      IO.writeLine("This would result in a divide by zero");
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    float data;
    if (IO.STATIC_FINAL_TRUE) {
      data = 0.0f; /* POTENTIAL FLAW: data is set to zero */
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (IO.STATIC_FINAL_TRUE) {
      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    int data;
    if (PRIVATE_STATIC_FINAL_FIVE == 5) {
      data = Integer.MIN_VALUE; /* Initialize data */
      {
        File file = new File("C:\\data.txt");
        FileInputStream streamFileInput = null;
        InputStreamReader readerInputStream = null;
        BufferedReader readerBuffered = null;
        try {
          /* read string from file into data */
          streamFileInput = new FileInputStream(file);
          readerInputStream = new InputStreamReader(streamFileInput, "UTF-8");
          readerBuffered = new BufferedReader(readerInputStream);
          /* POTENTIAL FLAW: Read data from a file */
          /* This will be reading the first "line" of the file, which
           * could be very long if there are little or no newlines in the file */
          String stringNumber = readerBuffered.readLine();
          if (stringNumber != null) /* avoid NPD incidental warnings */ {
            try {
              data = Integer.parseInt(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* Close stream reading objects */
          try {
            if (readerBuffered != null) {
              readerBuffered.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
          }

          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }

          try {
            if (streamFileInput != null) {
              streamFileInput.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing FileInputStream", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0;
    }

    if (PRIVATE_STATIC_FINAL_FIVE == 5) {
      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
        int result = (int) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    float data;
    if (IO.STATIC_FINAL_TRUE) {
      data = -1.0f; /* Initialize data */
      /* Read data using an outbound tcp connection */
      {
        Socket socket = null;
        BufferedReader readerBuffered = null;
        InputStreamReader readerInputStream = null;
        try {
          /* Read data using an outbound tcp connection */
          socket = new Socket("host.example.org", 39544);
          /* read input from socket */
          readerInputStream = new InputStreamReader(socket.getInputStream(), "UTF-8");
          readerBuffered = new BufferedReader(readerInputStream);
          /* POTENTIAL FLAW: Read data using an outbound tcp connection */
          String stringNumber = readerBuffered.readLine();
          if (stringNumber != null) // avoid NPD incidental warnings
          {
            try {
              data = Float.parseFloat(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* clean up stream reading objects */
          try {
            if (readerBuffered != null) {
              readerBuffered.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
          }

          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }

          /* clean up socket objects */
          try {
            if (socket != null) {
              socket.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing Socket", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (IO.STATIC_FINAL_TRUE) {
      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }
  /* goodB2G1() - use badsource and goodsink by changing second privateTrue to privateFalse */
  private void goodB2G1() throws Throwable {
    float data;

    if (privateTrue) {
      data = -1.0f; /* Initialize data */
      /* Read data using a listening tcp connection */
      {
        ServerSocket listener = null;
        Socket socket = null;
        BufferedReader readerBuffered = null;
        InputStreamReader readerInputStream = null;
        try {
          /* read input from socket */
          listener = new ServerSocket(39543);
          socket = listener.accept();
          readerInputStream = new InputStreamReader(socket.getInputStream(), "UTF-8");
          readerBuffered = new BufferedReader(readerInputStream);
          /* POTENTIAL FLAW: Read data using a listening tcp connection */
          String stringNumber = readerBuffered.readLine();
          if (stringNumber != null) // avoid NPD incidental warnings
          {
            try {
              data = Float.parseFloat(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* Close stream reading objects */
          try {
            if (readerBuffered != null) {
              readerBuffered.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
          }

          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }

          /* Close socket objects */
          try {
            if (socket != null) {
              socket.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing Socket", exceptIO);
          }

          try {
            if (listener != null) {
              listener.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing ServerSocket", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (privateFalse) {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
      IO.writeLine("Benign, fixed string");
    } else {

      /* FIX: Check for value of or near zero before dividing */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 / data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a divide by zero");
      }
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    int data;
    if (IO.staticTrue) {
      data = Integer.MIN_VALUE; /* Initialize data */
      /* Read data from a database */
      {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
          /* setup the connection */
          connection = IO.getDBConnection();
          /* prepare and execute a (hardcoded) query */
          preparedStatement = connection.prepareStatement("select name from users where id=0");
          resultSet = preparedStatement.executeQuery();
          /* POTENTIAL FLAW: Read data from a database query resultset */
          String stringNumber = resultSet.getString(1);
          if (stringNumber != null) /* avoid NPD incidental warnings */ {
            try {
              data = Integer.parseInt(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (SQLException exceptSql) {
          IO.logger.log(Level.WARNING, "Error with SQL statement", exceptSql);
        } finally {
          /* Close database objects */
          try {
            if (resultSet != null) {
              resultSet.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing ResultSet", exceptSql);
          }

          try {
            if (preparedStatement != null) {
              preparedStatement.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing PreparedStatement", exceptSql);
          }

          try {
            if (connection != null) {
              connection.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing Connection", exceptSql);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0;
    }

    if (IO.staticTrue) {
      /* FIX: Add a check to prevent an overflow from occurring */
      /* NOTE: Math.abs of the minimum int or long will return that same value, so we must check for it */
      if ((data != Integer.MIN_VALUE)
          && (data != Long.MIN_VALUE)
          && (Math.abs(data) <= (long) Math.sqrt(Integer.MAX_VALUE))) {
        int result = (int) (data * data);
        IO.writeLine("result: " + result);
      } else {
        IO.writeLine("data value is too large to perform squaring.");
      }
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    float data;
    if (privateTrue) {
      data = -1.0f; /* Initialize data */
      /* Read data from a database */
      {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
          /* setup the connection */
          connection = IO.getDBConnection();
          /* prepare and execute a (hardcoded) query */
          preparedStatement = connection.prepareStatement("select name from users where id=0");
          resultSet = preparedStatement.executeQuery();
          /* POTENTIAL FLAW: Read data from a database query resultset */
          String stringNumber = resultSet.getString(1);
          if (stringNumber != null) {
            try {
              data = Float.parseFloat(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (SQLException exceptSql) {
          IO.logger.log(Level.WARNING, "Error with SQL statement", exceptSql);
        } finally {
          /* Close database objects */
          try {
            if (resultSet != null) {
              resultSet.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing ResultSet", exceptSql);
          }

          try {
            if (preparedStatement != null) {
              preparedStatement.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing PreparedStatement", exceptSql);
          }

          try {
            if (connection != null) {
              connection.close();
            }
          } catch (SQLException exceptSql) {
            IO.logger.log(Level.WARNING, "Error closing Connection", exceptSql);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (privateTrue) {
      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }
  /* goodB2G2() - use badsource and goodsink by reversing statements in second if  */
  private void goodB2G2() throws Throwable {
    float data;
    if (IO.staticFive == 5) {
      data = -1.0f; /* Initialize data */
      /* read input from URLConnection */
      {
        URLConnection urlConnection = (new URL("http://www.example.org/")).openConnection();
        BufferedReader readerBuffered = null;
        InputStreamReader readerInputStream = null;
        try {
          readerInputStream = new InputStreamReader(urlConnection.getInputStream(), "UTF-8");
          readerBuffered = new BufferedReader(readerInputStream);
          /* POTENTIAL FLAW: Read data from a web server with URLConnection */
          /* This will be reading the first "line" of the response body,
           * which could be very long if there are no newlines in the HTML */
          String stringNumber = readerBuffered.readLine();
          if (stringNumber != null) {
            try {
              data = Float.parseFloat(stringNumber.trim());
            } catch (NumberFormatException exceptNumberFormat) {
              IO.logger.log(
                  Level.WARNING,
                  "Number format exception parsing data from string",
                  exceptNumberFormat);
            }
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* clean up stream reading objects */
          try {
            if (readerBuffered != null) {
              readerBuffered.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
          }

          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0.0f;
    }

    if (IO.staticFive == 5) {
      /* FIX: Check for value of or near zero before modulo */
      if (Math.abs(data) > 0.000001) {
        int result = (int) (100.0 % data);
        IO.writeLine(result);
      } else {
        IO.writeLine("This would result in a modulo by zero");
      }
    }
  }