mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
10.09.2015 b1994018d9cb7d26571157270d5296ac3a368b7c
OPENDJ-2522 rpm: error message in logs when uninstalling after an upgrade

The LockFileManager relies on lock files for locking.
Problem is that in this issue, the file paths computed during server startup
are not the same computed as the ones during server shutdown.

During startup, the Strings put into sharedLocks and sharedLockReferences are of the folowing form:
"/opt/opendj/./locks/backend-monitor.lock"
While on shutdown they have the following form:
"/opt/opendj/locks/backend-monitor.lock"
Since the strings do not equal, this message is shown.
This is worrying since it seems any lock checks will be wrong too. :(

The solution is to change Utils.getInstancePathFromInstallPath() to return a canonical path (instead of absolute)
2 files modified
50 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java 44 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -945,39 +945,24 @@
      }
    }
    BufferedReader reader;
    try
    {
      reader = new BufferedReader(new FileReader(instancePathFileName));
    }
    catch (Exception e)
    {
      return installPath;
    }
    // Read the first line and close the file.
    String line;
    try
    try (BufferedReader reader = new BufferedReader(new FileReader(instancePathFileName)))
    {
      line = reader.readLine();
      String line = reader.readLine();
      File instanceLoc = new File(line.trim());
      if (instanceLoc.isAbsolute())
      {
        return instanceLoc.getAbsolutePath();
        return getCanonicalPath(instanceLoc);
      }
      else
      {
        return new File(installPath + File.separator + instanceLoc.getPath()).getAbsolutePath();
        return getCanonicalPath(new File(installPath + File.separator + instanceLoc.getPath()));
      }
    }
    catch (Exception e)
    {
      return installPath;
    }
    finally
    {
      StaticUtils.close(reader);
    }
  }
  /**
@@ -1997,14 +1982,7 @@
    if (installDir == null)
    {
      File f = org.opends.quicksetup.Installation.getLocal().getRootDirectory();
      try
      {
        installDir = f.getCanonicalPath();
      }
      catch (Throwable t)
      {
        installDir = f.getAbsolutePath();
      }
      installDir = getCanonicalPath(f);
      if (installDir.lastIndexOf(File.separatorChar) != installDir.length() - 1)
      {
        installDir += File.separatorChar;
@@ -2014,6 +1992,18 @@
    return installDir;
  }
  private static String getCanonicalPath(File f)
  {
    try
    {
      return f.getCanonicalPath();
    }
    catch (IOException t)
    {
      return f.getAbsolutePath();
    }
  }
  private static List<String> getDsReplicationEquivalentCommandLine(String subcommand, UserData userData,
      Set<String> baseDNs, ServerDescriptor server)
  {
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java
@@ -318,16 +318,14 @@
  private File forceNonRelativeFile(File file) {
    // Do a best effort to avoid having a relative representation
    // (for instance to avoid having ../../../).
    String path = null;
    try
    {
      path = file.getCanonicalPath();
      return file.getCanonicalFile();
    }
    catch (IOException ioe)
    {
      path = file.getAbsolutePath();
      return file.getAbsoluteFile();
    }
    return new File(path);
  }
  /**