Program: 29199
Project: 29199
Buggy source:
public void postConstruct(){
  LogManager manager=LogManager.getLogManager();
  String cname=getClass().getName();
  if (manager != null) {
    logFileProperty=manager.getProperty(cname + "String_Node_Str");
  }
  if (logFileProperty == null || logFileProperty.trim().equals("String_Node_Str")) {
    logFileProperty=env.getInstanceRoot().getAbsolutePath() + File.separator + LOGS_DIR+ File.separator+ logFileName;
  }
  String filename=TranslatedConfigView.getTranslatedValue(logFileProperty).toString();
  File serverLog=new File(filename);
  absoluteServerLogName=filename;
  if (!serverLog.isAbsolute()) {
    serverLog=new File(env.getDomainRoot(),filename);
    absoluteServerLogName=env.getDomainRoot() + File.separator + filename;
  }
  changeFileName(serverLog);
  FileInputStream fs=null;
  String strLine="String_Node_Str";
  int odlFormatter=0;
  int uflFormatter=0;
  int otherFormatter=0;
  boolean mustRotate=false;
  try {
    fs=new FileInputStream(serverLog);
    BufferedReader br=new BufferedReader(new InputStreamReader(fs));
    while ((strLine=br.readLine()) != null) {
      strLine=strLine.trim();
      if (!strLine.equals("String_Node_Str")) {
        if (strLine.startsWith("String_Node_Str") && strLine.endsWith("String_Node_Str") && countOccurrences(strLine,'[') > 4) {
          odlFormatter++;
        }
 else         if (strLine.startsWith("String_Node_Str") && strLine.endsWith("String_Node_Str") && countOccurrences(strLine,'|') > 4) {
          uflFormatter++;
        }
 else {
          otherFormatter++;
        }
        if (odlFormatter > 0 && uflFormatter > 0) {
          mustRotate=true;
          break;
        }
 else         if (uflFormatter > 0 && otherFormatter > 0) {
          mustRotate=true;
          break;
        }
 else         if (otherFormatter > 0 && odlFormatter > 0) {
          mustRotate=true;
          break;
        }
        if (odlFormatter > 2 || uflFormatter > 2 || odlFormatter > 2) {
          break;
        }
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (odlFormatter > 0) {
    currentgffileHandlerFormatter="String_Node_Str";
  }
 else   if (uflFormatter > 0) {
    currentgffileHandlerFormatter="String_Node_Str";
  }
  pump=new Thread(){
    public void run(){
      try {
        while (!done.isSignalled()) {
          log();
        }
      }
 catch (      RuntimeException e) {
      }
    }
  }
;
  pump.setDaemon(true);
  pump.start();
  LogRecord lr=new LogRecord(Level.INFO,LogFacade.GF_VERSION_INFO);
  lr.setParameters(new Object[]{Version.getFullVersion()});
  lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
  lr.setThreadID((int)Thread.currentThread().getId());
  lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
  EarlyLogHandler.earlyMessages.add(lr);
  lr=new LogRecord(Level.INFO,LogFacade.LOG_FORMATTER_INFO);
  lr.setParameters(new Object[]{manager.getProperty(cname + "String_Node_Str")});
  lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
  lr.setThreadID((int)Thread.currentThread().getId());
  lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
  EarlyLogHandler.earlyMessages.add(lr);
  String rotationOnDateChange=manager.getProperty(cname + "String_Node_Str");
  if (rotationOnDateChange != null && !("String_Node_Str").equals(rotationOnDateChange.trim()) && Boolean.parseBoolean(rotationOnDateChange)) {
    dayBasedFileRotation=true;
    Long rotationTimeLimitValue=0L;
    int MILLIS_IN_DAY=1000 * 60 * 60* 24;
    Date date=new Date();
    SimpleDateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
    long systime=System.currentTimeMillis();
    String nextDate=dateFormat.format(date.getTime() + MILLIS_IN_DAY);
    Date nextDay=null;
    try {
      nextDay=dateFormat.parse(nextDate);
    }
 catch (    ParseException e) {
      nextDay=new Date();
      lr=new LogRecord(Level.WARNING,LogFacade.DATE_PARSING_FAILED);
      lr.setParameters(new Object[]{nextDate});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
    long nextsystime=nextDay.getTime();
    rotationTimeLimitValue=nextsystime - systime;
    Task rotationTask=new Task(){
      public Object run(){
        rotate();
        return null;
      }
    }
;
    LogRotationTimer.getInstance().startTimer(new LogRotationTimerTask(rotationTask,rotationTimeLimitValue / 60000));
  }
 else {
    Long rotationTimeLimitValue=0L;
    String propValue=null;
    try {
      propValue=manager.getProperty(cname + "String_Node_Str");
      if (propValue != null) {
        rotationTimeLimitValue=Long.parseLong(propValue);
      }
    }
 catch (    NumberFormatException e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
      lr.setParameters(new Object[]{propValue,"String_Node_Str"});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
    if (rotationTimeLimitValue != 0) {
      Task rotationTask=new Task(){
        public Object run(){
          rotate();
          return null;
        }
      }
;
      LogRotationTimer.getInstance().startTimer(new LogRotationTimerTask(rotationTask,rotationTimeLimitValue));
    }
  }
  Integer rotationLimitAttrValue=0;
  String propValue=null;
  try {
    propValue=manager.getProperty(cname + "String_Node_Str");
    if (propValue != null) {
      rotationLimitAttrValue=Integer.parseInt(propValue);
    }
  }
 catch (  NumberFormatException e) {
    lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
    lr.setParameters(new Object[]{propValue,"String_Node_Str"});
    lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
    lr.setThreadID((int)Thread.currentThread().getId());
    lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
    EarlyLogHandler.earlyMessages.add(lr);
  }
  setLimitForRotation(rotationLimitAttrValue);
  gffileHandlerFormatter=manager.getProperty(cname + "String_Node_Str");
  if (mustRotate) {
    rotate();
  }
 else   if (!currentgffileHandlerFormatter.equals("String_Node_Str") && gffileHandlerFormatter != null && !gffileHandlerFormatter.equals(currentgffileHandlerFormatter)) {
    rotate();
  }
  propValue=manager.getProperty(cname + "String_Node_Str");
  if (propValue != null) {
    try {
      flushFrequency=Integer.parseInt(propValue);
    }
 catch (    NumberFormatException e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
      lr.setParameters(new Object[]{propValue,"String_Node_Str"});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
  }
  if (flushFrequency <= 0)   flushFrequency=1;
  String formatterName=manager.getProperty(cname + "String_Node_Str");
  if (formatterName == null || UniformLogFormatter.class.getName().equals(formatterName)) {
    UniformLogFormatter formatterClass=null;
    if (agent != null) {
      formatterClass=new UniformLogFormatter(new AgentFormatterDelegate(agent));
      setFormatter(formatterClass);
    }
 else {
      formatterClass=new UniformLogFormatter();
      setFormatter(formatterClass);
    }
    if (formatterClass != null) {
      recordBeginMarker=manager.getProperty(cname + "String_Node_Str");
      if (recordBeginMarker == null || ("String_Node_Str").equals(recordBeginMarker)) {
        recordBeginMarker=RECORD_BEGIN_MARKER;
      }
      recordEndMarker=manager.getProperty(cname + "String_Node_Str");
      if (recordEndMarker == null || ("String_Node_Str").equals(recordEndMarker)) {
        recordEndMarker=RECORD_END_MARKER;
      }
      recordFieldSeparator=manager.getProperty(cname + "String_Node_Str");
      if (recordFieldSeparator == null || ("String_Node_Str").equals(recordFieldSeparator) || recordFieldSeparator.length() > 1) {
        recordFieldSeparator=RECORD_FIELD_SEPARATOR;
      }
      recordDateFormat=manager.getProperty(cname + "String_Node_Str");
      if (recordDateFormat != null && !("String_Node_Str").equals(recordDateFormat)) {
        SimpleDateFormat sdf=new SimpleDateFormat(recordDateFormat);
        try {
          sdf.format(new Date());
        }
 catch (        Exception e) {
          recordDateFormat=RECORD_DATE_FORMAT;
        }
      }
 else {
        recordDateFormat=RECORD_DATE_FORMAT;
      }
      formatterClass.setRecordBeginMarker(recordBeginMarker);
      formatterClass.setRecordEndMarker(recordEndMarker);
      formatterClass.setRecordDateFormat(recordDateFormat);
      formatterClass.setRecordFieldSeparator(recordFieldSeparator);
    }
  }
 else   if (ODLLogFormatter.class.getName().equals(formatterName)) {
    ODLLogFormatter formatterClass=null;
    if (agent != null) {
      formatterClass=new ODLLogFormatter(new AgentFormatterDelegate(agent));
      setFormatter(formatterClass);
    }
 else {
      formatterClass=new ODLLogFormatter();
      setFormatter(formatterClass);
    }
    String includeFields=manager.getProperty(LogManagerService.INCLUDE_FIELDS_PROPERTY);
    formatterClass.setIncludeFields(includeFields);
  }
 else {
    try {
      setFormatter((Formatter)this.getClass().getClassLoader().loadClass(formatterName).newInstance());
    }
 catch (    Exception e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_FORMATTER_CLASS_NAME);
      lr.setParameters(new Object[]{formatterName});
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      lr.setThrown(e);
      EarlyLogHandler.earlyMessages.add(lr);
    }
  }
  propValue=manager.getProperty(cname + "String_Node_Str");
  try {
    if (propValue != null) {
      maxHistoryFiles=Integer.parseInt(propValue);
    }
  }
 catch (  NumberFormatException e) {
    lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
    lr.setParameters(new Object[]{propValue,"String_Node_Str"});
    lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
    lr.setThreadID((int)Thread.currentThread().getId());
    lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
    EarlyLogHandler.earlyMessages.add(lr);
  }
  if (maxHistoryFiles < 0)   maxHistoryFiles=10;
}

Fixed version (ground truth):
public void postConstruct(){
  LogManager manager=LogManager.getLogManager();
  String cname=getClass().getName();
  logFileProperty=manager.getProperty(cname + "String_Node_Str");
  if (logFileProperty == null || logFileProperty.trim().equals("String_Node_Str")) {
    logFileProperty=env.getInstanceRoot().getAbsolutePath() + File.separator + LOGS_DIR+ File.separator+ logFileName;
  }
  String filename=TranslatedConfigView.getTranslatedValue(logFileProperty).toString();
  File serverLog=new File(filename);
  absoluteServerLogName=filename;
  if (!serverLog.isAbsolute()) {
    serverLog=new File(env.getDomainRoot(),filename);
    absoluteServerLogName=env.getDomainRoot() + File.separator + filename;
  }
  changeFileName(serverLog);
  BufferedReader br=null;
  String strLine="String_Node_Str";
  int odlFormatter=0;
  int uflFormatter=0;
  int otherFormatter=0;
  boolean mustRotate=false;
  try {
    br=new BufferedReader(new FileReader(serverLog));
    while ((strLine=br.readLine()) != null) {
      strLine=strLine.trim();
      if (!strLine.equals("String_Node_Str")) {
        if (strLine.startsWith("String_Node_Str") && strLine.endsWith("String_Node_Str") && countOccurrences(strLine,'[') > 4) {
          odlFormatter++;
        }
 else         if (strLine.startsWith("String_Node_Str") && strLine.endsWith("String_Node_Str") && countOccurrences(strLine,'|') > 4) {
          uflFormatter++;
        }
 else {
          otherFormatter++;
        }
        if (odlFormatter > 0 && uflFormatter > 0) {
          mustRotate=true;
          break;
        }
 else         if (uflFormatter > 0 && otherFormatter > 0) {
          mustRotate=true;
          break;
        }
 else         if (otherFormatter > 0 && odlFormatter > 0) {
          mustRotate=true;
          break;
        }
        if (odlFormatter > 2 || uflFormatter > 2 || odlFormatter > 2) {
          break;
        }
      }
    }
  }
 catch (  Exception e) {
    ErrorManager em=getErrorManager();
    if (em != null) {
      em.error(e.getMessage(),e,ErrorManager.GENERIC_FAILURE);
    }
  }
 finally {
    if (br != null) {
      try {
        br.close();
      }
 catch (      Exception e) {
      }
    }
  }
  if (odlFormatter > 0) {
    currentgffileHandlerFormatter="String_Node_Str";
  }
 else   if (uflFormatter > 0) {
    currentgffileHandlerFormatter="String_Node_Str";
  }
  pump=new Thread(){
    public void run(){
      try {
        while (!done.isSignalled()) {
          log();
        }
      }
 catch (      RuntimeException e) {
      }
    }
  }
;
  pump.setDaemon(true);
  pump.start();
  LogRecord lr=new LogRecord(Level.INFO,LogFacade.GF_VERSION_INFO);
  lr.setParameters(new Object[]{Version.getFullVersion()});
  lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
  lr.setThreadID((int)Thread.currentThread().getId());
  lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
  EarlyLogHandler.earlyMessages.add(lr);
  String propValue=null;
  propValue=manager.getProperty(cname + "String_Node_Str");
  boolean rotationOnDateChange=false;
  if (propValue != null) {
    rotationOnDateChange=Boolean.parseBoolean(propValue);
  }
  if (rotationOnDateChange) {
    dayBasedFileRotation=true;
    Long rotationTimeLimitValue=0L;
    int MILLIS_IN_DAY=1000 * 60 * 60* 24;
    Date date=new Date();
    SimpleDateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
    long systime=System.currentTimeMillis();
    String nextDate=dateFormat.format(date.getTime() + MILLIS_IN_DAY);
    Date nextDay=null;
    try {
      nextDay=dateFormat.parse(nextDate);
    }
 catch (    ParseException e) {
      nextDay=new Date();
      lr=new LogRecord(Level.WARNING,LogFacade.DATE_PARSING_FAILED);
      lr.setParameters(new Object[]{nextDate});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
    long nextsystime=nextDay.getTime();
    rotationTimeLimitValue=nextsystime - systime;
    Task rotationTask=new Task(){
      public Object run(){
        rotate();
        return null;
      }
    }
;
    LogRotationTimer.getInstance().startTimer(new LogRotationTimerTask(rotationTask,rotationTimeLimitValue / 60000));
  }
 else {
    Long rotationTimeLimitValue=0L;
    try {
      propValue=manager.getProperty(cname + "String_Node_Str");
      if (propValue != null) {
        rotationTimeLimitValue=Long.parseLong(propValue);
      }
    }
 catch (    NumberFormatException e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
      lr.setParameters(new Object[]{propValue,"String_Node_Str"});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
    if (rotationTimeLimitValue != 0) {
      Task rotationTask=new Task(){
        public Object run(){
          rotate();
          return null;
        }
      }
;
      LogRotationTimer.getInstance().startTimer(new LogRotationTimerTask(rotationTask,rotationTimeLimitValue));
    }
  }
  Integer rotationLimitAttrValue=0;
  try {
    propValue=manager.getProperty(cname + "String_Node_Str");
    if (propValue != null) {
      rotationLimitAttrValue=Integer.parseInt(propValue);
    }
  }
 catch (  NumberFormatException e) {
    lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
    lr.setParameters(new Object[]{propValue,"String_Node_Str"});
    lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
    lr.setThreadID((int)Thread.currentThread().getId());
    lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
    EarlyLogHandler.earlyMessages.add(lr);
  }
  setLimitForRotation(rotationLimitAttrValue);
  gffileHandlerFormatter=manager.getProperty(cname + "String_Node_Str");
  if (mustRotate) {
    rotate();
  }
 else   if (!currentgffileHandlerFormatter.equals("String_Node_Str") && gffileHandlerFormatter != null && !gffileHandlerFormatter.equals(currentgffileHandlerFormatter)) {
    rotate();
  }
  propValue=manager.getProperty(cname + "String_Node_Str");
  if (propValue != null) {
    try {
      flushFrequency=Integer.parseInt(propValue);
    }
 catch (    NumberFormatException e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
      lr.setParameters(new Object[]{propValue,"String_Node_Str"});
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      EarlyLogHandler.earlyMessages.add(lr);
    }
  }
  if (flushFrequency <= 0)   flushFrequency=1;
  String formatterName=manager.getProperty(cname + "String_Node_Str");
  formatterName=(formatterName == null) ? UniformLogFormatter.class.getName() : formatterName;
  lr=new LogRecord(Level.INFO,LogFacade.LOG_FORMATTER_INFO);
  lr.setParameters(new Object[]{formatterName});
  lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
  lr.setThreadID((int)Thread.currentThread().getId());
  lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
  EarlyLogHandler.earlyMessages.add(lr);
  if (UniformLogFormatter.class.getName().equals(formatterName)) {
    UniformLogFormatter formatterClass=null;
    if (agent != null) {
      formatterClass=new UniformLogFormatter(new AgentFormatterDelegate(agent));
      setFormatter(formatterClass);
    }
 else {
      formatterClass=new UniformLogFormatter();
      setFormatter(formatterClass);
    }
    if (formatterClass != null) {
      recordBeginMarker=manager.getProperty(cname + "String_Node_Str");
      if (recordBeginMarker == null || ("String_Node_Str").equals(recordBeginMarker)) {
        recordBeginMarker=RECORD_BEGIN_MARKER;
      }
      recordEndMarker=manager.getProperty(cname + "String_Node_Str");
      if (recordEndMarker == null || ("String_Node_Str").equals(recordEndMarker)) {
        recordEndMarker=RECORD_END_MARKER;
      }
      recordFieldSeparator=manager.getProperty(cname + "String_Node_Str");
      if (recordFieldSeparator == null || ("String_Node_Str").equals(recordFieldSeparator) || recordFieldSeparator.length() > 1) {
        recordFieldSeparator=RECORD_FIELD_SEPARATOR;
      }
      recordDateFormat=manager.getProperty(cname + "String_Node_Str");
      if (recordDateFormat != null && !("String_Node_Str").equals(recordDateFormat)) {
        SimpleDateFormat sdf=new SimpleDateFormat(recordDateFormat);
        try {
          sdf.format(new Date());
        }
 catch (        Exception e) {
          recordDateFormat=RECORD_DATE_FORMAT;
        }
      }
 else {
        recordDateFormat=RECORD_DATE_FORMAT;
      }
      formatterClass.setRecordBeginMarker(recordBeginMarker);
      formatterClass.setRecordEndMarker(recordEndMarker);
      formatterClass.setRecordDateFormat(recordDateFormat);
      formatterClass.setRecordFieldSeparator(recordFieldSeparator);
    }
  }
 else   if (ODLLogFormatter.class.getName().equals(formatterName)) {
    ODLLogFormatter formatterClass=null;
    if (agent != null) {
      formatterClass=new ODLLogFormatter(new AgentFormatterDelegate(agent));
      setFormatter(formatterClass);
    }
 else {
      formatterClass=new ODLLogFormatter();
      setFormatter(formatterClass);
    }
    String includeFields=manager.getProperty(LogManagerService.INCLUDE_FIELDS_PROPERTY);
    formatterClass.setIncludeFields(includeFields);
  }
 else {
    try {
      setFormatter((Formatter)this.getClass().getClassLoader().loadClass(formatterName).newInstance());
    }
 catch (    Exception e) {
      lr=new LogRecord(Level.WARNING,LogFacade.INVALID_FORMATTER_CLASS_NAME);
      lr.setParameters(new Object[]{formatterName});
      lr.setThreadID((int)Thread.currentThread().getId());
      lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
      lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
      lr.setThrown(e);
      EarlyLogHandler.earlyMessages.add(lr);
    }
  }
  propValue=manager.getProperty(cname + "String_Node_Str");
  try {
    if (propValue != null) {
      maxHistoryFiles=Integer.parseInt(propValue);
    }
  }
 catch (  NumberFormatException e) {
    lr=new LogRecord(Level.WARNING,LogFacade.INVALID_ATTRIBUTE_VALUE);
    lr.setParameters(new Object[]{propValue,"String_Node_Str"});
    lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
    lr.setThreadID((int)Thread.currentThread().getId());
    lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
    EarlyLogHandler.earlyMessages.add(lr);
  }
  if (maxHistoryFiles < 0)   maxHistoryFiles=10;
}