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

Resource table locks on an attempt to acquire resources with duplicate names

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • jt4.4.1
    • jt4.2.1
    • tools
    • b08
    • generic
    • generic
    • Verified

    Description

      The ResourceTable locks on an attempt to acquire resources passing a array with duplicate names. Here is an example that demonstrates this:

      import com.sun.javatest.ResourceTable;
      public class Test {

          public static void main(String[] args) throws InterruptedException {
              ResourceTable table = new ResourceTable();
              String[] locks = {"a", "b", "a"};
              boolean ok = table.acquire(locks, 3000);
              try {
                  if (!ok) {
                      System.out.println("Timeout");
                  } else {
                      System.out.println("Do work");
                  }
              } finally {
                  table.release(locks);
             }
          }
      }


      The program below prints "Timeout" because the "a" resource occurs twice in "locks".


      I think that it would be better if the ResourceTable removes duplicated resource names from the given array before acquiring the locks. Btw, that seems to be the initial design goal back in 1999 when the SortedStringVector.sort method had used for sorting the names, but this was changed later during the migration to the java.util.Arrays utilities.

      Attachments

        Activity

          People

            bkurotsu Brian Kurotsuchi (Inactive)
            agavrilosunw Alexey Gavrilov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: