At 06:48 AM 12/10/2004, Jacob Kjome wrote:

Ceki,

FixedWindowRollingPolicy is still broken. Try providing a config file without specifying the "fileNamePattern" param and watch it blow up. Note the following code...

    if (fileNamePatternStr != null) {
      fileNamePattern = new FileNamePattern(fileNamePatternStr);
      determineCompressionMode();
    }

    IntegerTokenConverter itc = fileNamePattern.getIntegerTokenConverter();


You only initialize the fileNamePattern object only if the string was provided. If it wasn't, it isn't initialized. And then in the very next line of code, you use the fileNamePattern object, resulting in a NullPointerException. It is then used at least 7 other times in the class. Why haven't you taken the same approach here as you did in TimeBasedRollingPolicy as I recommended yesterday?....


  public void activateOptions() {
    // find out period from the filename pattern
    if (fileNamePatternStr != null) {
      fileNamePattern = new FileNamePattern(fileNamePatternStr);
      determineCompressionMode();
    } else {
      getLogger().warn(FNP_NOT_SET);
      getLogger().warn(SEE_FNP_NOT_SET);
      throw new IllegalStateException(FNP_NOT_SET + SEE_FNP_NOT_SET);
    }
    .....
    .....

In short, I forgot the patently obvious. FileNamePattern is always required whereas ActiveFileName is only required for FixedWindowRollingPolicy but not for TimeBasedRollingPolicy.

As you proposed, the approach taken in TimeBasedRollingPolicy should
also be applied to FixedWindowRollingPolicy. Would you care to commit
these changes? Note that the javadocs as well as
http://logging.apache.org/log4j/docs/codes.html would also need to be
updated.

Many thanks in advance,

--
Ceki G�lc�

ps. Thanks for bearing with me.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to