Program: 30929
Project: 30929
Buggy source:
/** 
 * Sets path member variable to partition directory for the given timestamp and partitionLo and partitionHi to partition interval in millis. These values are determined based on input timestamp and value of partitionBy. For any given timestamp this method will determine either day, month or year interval timestamp falls to. Partition directory name is ISO string of interval start. <p> Because this method modifies "path" member variable, be sure path is trimmed to original state withing try..finally block.
 * @param timestamp               to determine interval for
 * @param updatePartitionInterval flag indicating that partition interval partitionLo andpartitionHi have to be updated as well.
 */
private void setStateForTimestamp(long timestamp,boolean updatePartitionInterval){
  int y, m, d;
  boolean leap;
  path.put(Path.SEPARATOR);
switch (partitionBy) {
case PartitionBy.DAY:
    y=Dates.getYear(timestamp);
  leap=Dates.isLeapYear(y);
m=Dates.getMonthOfYear(timestamp,y,leap);
d=Dates.getDayOfMonth(timestamp,y,m,leap);
DateFormatUtils.append000(path,y);
path.put('-');
DateFormatUtils.append0(path,m);
path.put('-');
DateFormatUtils.append0(path,d);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionLo+=Dates.monthOfYearMillis(m,leap);
partitionLo+=(d - 1) * Dates.DAY_MILLIS;
partitionHi=partitionLo + 24 * Dates.HOUR_MILLIS;
}
break;
case PartitionBy.MONTH:
y=Dates.getYear(timestamp);
leap=Dates.isLeapYear(y);
m=Dates.getMonthOfYear(timestamp,y,leap);
DateFormatUtils.append000(path,y);
path.put('-');
DateFormatUtils.append0(path,m);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionLo+=Dates.monthOfYearMillis(m,leap);
partitionHi=partitionLo + Dates.getDaysPerMonth(m,leap) * 24L * Dates.HOUR_MILLIS;
}
break;
case PartitionBy.YEAR:
y=Dates.getYear(timestamp);
leap=Dates.isLeapYear(y);
DateFormatUtils.append000(path,y);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionHi=Dates.addYear(partitionLo,1);
}
break;
default :
path.put(DEFAULT_PARTITION_NAME);
partitionLo=Long.MIN_VALUE;
partitionHi=Long.MAX_VALUE;
}
}

Fixed version (ground truth):
/** 
 * Sets path member variable to partition directory for the given timestamp and partitionLo and partitionHi to partition interval in millis. These values are determined based on input timestamp and value of partitionBy. For any given timestamp this method will determine either day, month or year interval timestamp falls to. Partition directory name is ISO string of interval start. <p> Because this method modifies "path" member variable, be sure path is trimmed to original state withing try..finally block.
 * @param timestamp               to determine interval for
 * @param updatePartitionInterval flag indicating that partition interval partitionLo andpartitionHi have to be updated as well.
 */
private void setStateForTimestamp(long timestamp,boolean updatePartitionInterval){
  int y, m, d;
  boolean leap;
  path.put(Path.SEPARATOR);
switch (partitionBy) {
case PartitionBy.DAY:
    y=Dates.getYear(timestamp);
  leap=Dates.isLeapYear(y);
m=Dates.getMonthOfYear(timestamp,y,leap);
d=Dates.getDayOfMonth(timestamp,y,m,leap);
DateFormatUtils.append000(path,y);
path.put('-');
DateFormatUtils.append0(path,m);
path.put('-');
DateFormatUtils.append0(path,d);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionLo+=Dates.monthOfYearMillis(m,leap);
partitionLo+=(d - 1) * Dates.DAY_MILLIS;
partitionHi=partitionLo + 24 * Dates.HOUR_MILLIS;
}
break;
case PartitionBy.MONTH:
y=Dates.getYear(timestamp);
leap=Dates.isLeapYear(y);
m=Dates.getMonthOfYear(timestamp,y,leap);
DateFormatUtils.append000(path,y);
path.put('-');
DateFormatUtils.append0(path,m);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionLo+=Dates.monthOfYearMillis(m,leap);
partitionHi=partitionLo + Dates.getDaysPerMonth(m,leap) * 24L * Dates.HOUR_MILLIS;
}
break;
case PartitionBy.YEAR:
y=Dates.getYear(timestamp);
leap=Dates.isLeapYear(y);
DateFormatUtils.append000(path,y);
if (updatePartitionInterval) {
partitionLo=Dates.yearMillis(y,leap);
partitionHi=Dates.addYear(partitionLo,1);
}
break;
default :
path.put(DEFAULT_PARTITION_NAME);
partitionLo=Long.MIN_VALUE;
partitionHi=Long.MAX_VALUE;
break;
}
}