Program: 166918
Project: 166918
Buggy source:
private String valueToStreamString(PropertyType propertyType,Object value){
  String result;
  if (value == null) {
    result=getBatchNull();
  }
 else {
switch (propertyType) {
case ZONEDDATETIME:
      ZonedDateTime zonedDateTime=(ZonedDateTime)value;
    LocalDateTime localDateTime=zonedDateTime.toLocalDateTime();
  TimeZone timeZone=TimeZone.getTimeZone(zonedDateTime.getZone().getId());
result=localDateTime.toString() + COPY_COMMAND_DELIMITER + timeZone.getID();
break;
case PERIOD:
Period period=(Period)value;
result=period.getYears() + COPY_COMMAND_DELIMITER + period.getMonths()+ COPY_COMMAND_DELIMITER+ period.getDays();
break;
case DURATION:
Duration duration=(Duration)value;
result=duration.getSeconds() + COPY_COMMAND_DELIMITER + duration.getNano();
break;
case LOCALTIME:
LocalTime lt=(LocalTime)value;
result=shiftDST(lt).toString();
break;
case ZONEDDATETIME_ARRAY:
ZonedDateTime[] zonedDateTimes=(ZonedDateTime[])value;
StringBuilder sb=new StringBuilder();
sb.append("String_Node_Str");
int length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
zonedDateTime=zonedDateTimes[i];
localDateTime=zonedDateTime.toLocalDateTime();
result=localDateTime.toString();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
zonedDateTime=zonedDateTimes[i];
timeZone=TimeZone.getTimeZone(zonedDateTime.getZone().getId());
result=timeZone.getID();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case DURATION_ARRAY:
Duration[] durations=(Duration[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
duration=durations[i];
sb.append(duration.getSeconds());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
duration=durations[i];
sb.append(duration.getNano());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case PERIOD_ARRAY:
Period[] periods=(Period[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getYears());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getMonths());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getDays());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case LOCALTIME_ARRAY:
LocalTime[] localTimes=(LocalTime[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
LocalTime localTime=localTimes[i];
result=shiftDST(localTime).toString();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case JSON_ARRAY:
throw SqlgExceptions.invalidPropertyType(propertyType);
case BYTE_ARRAY:
return PGbytea.toPGString((byte[])SqlgUtil.convertByteArrayToPrimitiveArray((Byte[])value));
case byte_ARRAY:
return PGbytea.toPGString((byte[])value);
default :
if (value.getClass().isArray()) {
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
String valueOfArray=java.lang.reflect.Array.get(value,i).toString();
sb.append(escapeSpecialCharacters(valueOfArray));
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
}
result=escapeSpecialCharacters(value.toString());
}
}
return result;
}

Fixed version (ground truth):
private String valueToStreamString(PropertyType propertyType,Object value){
  String result;
  if (value == null) {
    result=getBatchNull();
  }
 else {
switch (propertyType) {
case ZONEDDATETIME:
      ZonedDateTime zonedDateTime=(ZonedDateTime)value;
    LocalDateTime localDateTime=zonedDateTime.toLocalDateTime();
  TimeZone timeZone=TimeZone.getTimeZone(zonedDateTime.getZone());
result=localDateTime.toString() + COPY_COMMAND_DELIMITER + timeZone.getID();
break;
case PERIOD:
Period period=(Period)value;
result=period.getYears() + COPY_COMMAND_DELIMITER + period.getMonths()+ COPY_COMMAND_DELIMITER+ period.getDays();
break;
case DURATION:
Duration duration=(Duration)value;
result=duration.getSeconds() + COPY_COMMAND_DELIMITER + duration.getNano();
break;
case LOCALTIME:
LocalTime lt=(LocalTime)value;
result=shiftDST(lt).toString();
break;
case ZONEDDATETIME_ARRAY:
ZonedDateTime[] zonedDateTimes=(ZonedDateTime[])value;
StringBuilder sb=new StringBuilder();
sb.append("String_Node_Str");
int length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
zonedDateTime=zonedDateTimes[i];
localDateTime=zonedDateTime.toLocalDateTime();
result=localDateTime.toString();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
zonedDateTime=zonedDateTimes[i];
timeZone=TimeZone.getTimeZone(zonedDateTime.getZone());
result=timeZone.getID();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case DURATION_ARRAY:
Duration[] durations=(Duration[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
duration=durations[i];
sb.append(duration.getSeconds());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
duration=durations[i];
sb.append(duration.getNano());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case PERIOD_ARRAY:
Period[] periods=(Period[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getYears());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getMonths());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
sb.append(COPY_COMMAND_DELIMITER);
sb.append("String_Node_Str");
for (int i=0; i < length; i++) {
period=periods[i];
sb.append(period.getDays());
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case LOCALTIME_ARRAY:
LocalTime[] localTimes=(LocalTime[])value;
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
LocalTime localTime=localTimes[i];
result=shiftDST(localTime).toString();
sb.append(result);
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
case JSON_ARRAY:
throw SqlgExceptions.invalidPropertyType(propertyType);
case BYTE_ARRAY:
return PGbytea.toPGString((byte[])SqlgUtil.convertByteArrayToPrimitiveArray((Byte[])value));
case byte_ARRAY:
return PGbytea.toPGString((byte[])value);
default :
if (value.getClass().isArray()) {
sb=new StringBuilder();
sb.append("String_Node_Str");
length=java.lang.reflect.Array.getLength(value);
for (int i=0; i < length; i++) {
String valueOfArray=java.lang.reflect.Array.get(value,i).toString();
sb.append(escapeSpecialCharacters(valueOfArray));
if (i < length - 1) {
sb.append("String_Node_Str");
}
}
sb.append("String_Node_Str");
return sb.toString();
}
result=escapeSpecialCharacters(value.toString());
}
}
return result;
}