Class CommonUtils

java.lang.Object
com.ultikits.ultitools.utils.CommonUtils

public class CommonUtils extends Object
Common utility class providing general-purpose helper methods. This class contains utility methods used throughout the UltiTools plugin.
Since:
6.0.0
Author:
wisdomme
  • Constructor Details

    • CommonUtils

      public CommonUtils()
  • Method Details

    • getUltiToolsUUID

      public static String getUltiToolsUUID() throws IOException
      get UltiTools UUID

      Reads the current UUID without writing to the credential store when one already exists -- only the first-ever call (or a rare concurrent race against another first-ever call) needs to write. WR-01 (08-REVIEW.md): the previous unconditional CredentialStore.update(java.util.function.UnaryOperator<java.util.Map<java.lang.String, java.lang.Object>>) call rewrote the live-credential file on every invocation, including the common already-exists case, which needlessly widened the write window on the single-owner store.

      A credential file that exists but is empty, whitespace-only or not valid JSON is never replaced by a fresh identity (#573): this method fails with an IOException that names the file and leaves it untouched. Only a missing file starts a new UUID. Every failure of the credential store is reported as this method's declared IOException, never as an unchecked exception, so a caller's catch (IOException e) covers it.

      Returns:
      UUID
      Throws:
      IOException - if the credential file cannot be read or written, or exists but cannot be read as a credential document
    • readOrCreateUuid

      private static String readOrCreateUuid() throws IOException
      Throws:
      IOException