private static Optional getSpec()

in src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/BlockedThreadsConfigurator.java [133:149]


  private static Optional<Threshold> getSpec(String spec) {
    int equals = spec.lastIndexOf('=');
    if (equals != -1) {
      Optional<Integer> maybeThreshold = isThresholdDefined(spec.substring(equals + 1));
      if (maybeThreshold.isPresent()) {
        return Optional.of(new Threshold(spec.substring(0, equals).trim(), maybeThreshold.get()));
      }
    } else {
      Optional<Integer> maybeThreshold = isThresholdDefined(spec);
      if (maybeThreshold.isPresent()) {
        return Optional.of(new Threshold(maybeThreshold.get()));
      }
    }

    log.warn("Invalid configuration of blocked threads threshold [{}]", spec);
    return Optional.empty();
  }