private synchronized int insertNewValue(@Nullable String value) {
    if (value != null && StringUtil.containsLineBreak(value)) {
      throw new IllegalArgumentException("SimpleStringPersistentEnumerator doesn't support multi-line strings: [" + value + "]");
    }

    //re-check under lock:
    int id = valueToId.getInt(value);
    if (id != valueToId.defaultReturnValue()) {
      return id;
    }

    //CopyOnWrite: it is possible to do CoW without a lock, with CAS only -- but it is hard to keep consistent
    //             on-disk representation: it is very possible to have a correct version in memory, but outdated
    //             version stored on disk -- and additional efforts needed to prevent it.
    //             So locking seems to be the simpler choice: this enumerator is aimed for ~small datasets,
    //             i.e., total number of updates must be very limited.

    // do not use nameToId.size because enumeration file may have duplicates on different lines
    int newId = idToValue.length + 1;

    String[] newIdToName = Arrays.copyOf(idToValue, idToValue.length + 1);
    newIdToName[newId - 1] = value;
    idToValue = newIdToName;

    Object2IntMap<String> newValueToId = new Object2IntOpenHashMap<>(valueToId);
    newValueToId.put(value, newId);
    valueToId = newValueToId;

    forceDiskSync();

    return newId;
  }
private synchronized int insertNewValue(@Nullable String value)