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

boli
22.23.2007 753d9aeb7050b49c993e8883fae7bdbcbe5dc927
Fix for issue where the size of log files might exceed the max file size set in the size limit rotation policy. It now checks to see if the new message will exceed the limit before writing instead of after.

Fix for issue 2301
1 files modified
32 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/loggers/MultifileTextWriter.java 32 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/loggers/MultifileTextWriter.java
@@ -524,8 +524,35 @@
   */
  public void writeRecord(String record)
  {
    // Assume each character is 1 byte ASCII
    int length = record.length();
    int size = length;
    char c;
    for (int i=0; i < length; i++)
    {
      c = record.charAt(i);
      if (c != (byte) (c & 0x0000007F))
      {
        try
        {
          // String contains a non ASCII character. Fall back to getBytes.
          size = record.getBytes("UTF-8").length;
        }
        catch(Exception e)
        {
          size = length * 2;
        }
        break;
      }
    }
    synchronized(this)
    {
      if(sizeLimit > 0 && outputStream.written + size + 1 >= sizeLimit)
      {
        rotate();
      }
      try
      {
        writer.write(record);
@@ -541,11 +568,6 @@
        flush();
      }
    }
    if(sizeLimit > 0 && outputStream.written >= sizeLimit)
    {
      rotate();
    }
  }
  /**