Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901054

RegressionScript.getTimeoutFactor() is not thread safe

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • jtreg4.1
    • None
    • tools
    • None
    • b10

      See JDK-8039086 for some background.

      The issue here is that the following code is not thread safe. A second thread can read cacheJavaTestTimeoutFactor as having the value 1 while it is still being set up by the first thread.

         protected float getTimeoutFactor() {
              if (cacheJavaTestTimeoutFactor == -1) {
                  cacheJavaTestTimeoutFactor = 1; // default
                  try {
                      // use [1] to get the floating point timeout factor
                      String f = (regEnv == null ? null : regEnv.lookup("javatestTimeoutFactor")[1]);
                      if (f != null)
                          cacheJavaTestTimeoutFactor = Float.parseFloat(f);
                  } catch (TestEnvironment.Fault e) {
                  } catch (NumberFormatException e) {
                  }
              }
              return cacheJavaTestTimeoutFactor;
          }

          private static float cacheJavaTestTimeoutFactor = -1;

            jjg Jonathan Gibbons
            sla Staffan Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: