private static int indexOfClosingParenthesis(String s, int index) {
    int depth = 0;
    int length = s.length();

    while (index < length) {
      char c = s.charAt(index++);
      if (c == '(') {
        ++depth;
      } else if (c == ')') {
        if (--depth == 0) {
          return index;
        }
      }
    }
    return -1;
  }
Find the index of the closing parenthesis in the given string.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java