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

Jean-Noël Rouvignac
20.26.2016 79bcc8f168174bc1aa57d592d60ad5fb8de797e6
opendj-server-legacy/src/main/java/org/opends/server/loggers/GZIPAction.java
@@ -64,11 +64,6 @@
  @Override
  public boolean execute()
  {
    FileInputStream fis = null;
    GZIPOutputStream gzip = null;
    boolean inputStreamOpen = false;
    boolean outputStreamOpen = false;
    try
    {
      if(!originalFile.exists())
@@ -77,25 +72,18 @@
        return false;
      }
      fis = new FileInputStream(originalFile);
      inputStreamOpen = true;
      FileOutputStream fos = new FileOutputStream(newFile);
      gzip = new GZIPOutputStream(fos);
      outputStreamOpen = true;
      byte[] buf = new byte[8192];
      int n;
      while((n = fis.read(buf)) != -1)
      try (FileInputStream fis = new FileInputStream(originalFile);
          FileOutputStream fos = new FileOutputStream(newFile);
          GZIPOutputStream gzip = new GZIPOutputStream(fos);)
      {
        gzip.write(buf, 0, n);
        byte[] buf = new byte[8192];
        int n;
        while ((n = fis.read(buf)) != -1)
        {
          gzip.write(buf, 0, n);
        }
      }
      gzip.close();
      outputStreamOpen = false;
      fis.close();
      inputStreamOpen = false;
      if(deleteOriginal && !originalFile.delete())
      {
        System.err.println("Cannot delete original file:" + originalFile);
@@ -106,34 +94,7 @@
    } catch(IOException ioe)
    {
      logger.traceException(ioe);
      if (inputStreamOpen)
      {
        try
        {
          fis.close();
        }
        catch (Exception fe)
        {
         logger.traceException(fe);
          // Cannot do much. Ignore.
        }
      }
      if (outputStreamOpen)
      {
        try
        {
          gzip.close();
        }
        catch (Exception ge)
        {
          logger.traceException(ge);
          // Cannot do much. Ignore.
        }
      }
      return false;
    }
  }
}