Program: 6033
Project: 6033
Buggy source:
public final void saveTicket(final TicketInfo ticket,final String location) throws BasicException {
  Transaction t=new Transaction(s){
    public Object transact() throws BasicException {
      if (ticket.getTicketId() == 0) {
switch (ticket.getTicketType()) {
case TicketInfo.RECEIPT_NORMAL:
          ticket.setTicketId(getNextTicketIndex().intValue());
        break;
case TicketInfo.RECEIPT_REFUND:
      ticket.setTicketId(getNextTicketRefundIndex().intValue());
    break;
case TicketInfo.RECEIPT_PAYMENT:
  ticket.setTicketId(getNextTicketPaymentIndex().intValue());
break;
default :
throw new BasicException();
}
}
new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE).exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,ticket.getId());
setString(2,ticket.getActiveCash());
setTimestamp(3,ticket.getDate());
try {
ByteArrayOutputStream o=new ByteArrayOutputStream();
ticket.getProperties().storeToXML(o,AppLocal.APP_NAME,"String_Node_Str");
setBytes(4,o.toByteArray());
}
 catch (IOException e) {
setBytes(4,null);
}
}
}
);
new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE).exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,ticket.getId());
setInt(2,ticket.getTicketType());
setInt(3,ticket.getTicketId());
setString(4,ticket.getUser().getId());
setString(5,ticket.getCustomerId());
}
}
);
SentenceExec ticketlineinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteBuilder.INSTANCE);
for (TicketLineInfo l : ticket.getLines()) {
ticketlineinsert.exec(l);
if (l.getProductID() != null) {
getStockDiaryInsert().exec(new Object[]{UUID.randomUUID().toString(),ticket.getDate(),l.getMultiply() < 0.0 ? MovementReason.IN_REFUND.getKey() : MovementReason.OUT_SALE.getKey(),location,l.getProductID(),new Double(-l.getMultiply()),new Double(l.getPrice())});
}
}
SentenceExec paymentinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE);
for (final PaymentInfo p : ticket.getPayments()) {
paymentinsert.exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,UUID.randomUUID().toString());
setString(2,ticket.getId());
setString(3,p.getName());
setDouble(4,p.getTotal());
setString(5,ticket.getTransactionID());
setString(6,ticket.getReturnMessage());
}
}
);
if ("String_Node_Str".equals(p.getName()) || "String_Node_Str".equals(p.getName())) {
ticket.getCustomer().updateCurDebt(p.getTotal(),ticket.getDate());
getDebtUpdate().exec(new DataParams(){
public void writeValues() throws BasicException {
setDouble(1,ticket.getCustomer().getCurdebt());
setTimestamp(2,ticket.getCustomer().getCurdate());
setString(3,ticket.getCustomer().getId());
}
}
);
}
}
SentenceExec taxlinesinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE);
if (ticket.getTaxes() != null) {
for (final TicketTaxInfo tickettax : ticket.getTaxes()) {
taxlinesinsert.exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,UUID.randomUUID().toString());
setString(2,ticket.getId());
setString(3,tickettax.getTaxInfo().getId());
setDouble(4,tickettax.getSubTotal());
setDouble(5,tickettax.getTax());
}
}
);
}
}
return null;
}
}
;
t.execute();
}

Fixed version (ground truth):
public final void saveTicket(final TicketInfo ticket,final String location) throws BasicException {
  Transaction t=new Transaction(s){
    public Object transact() throws BasicException {
      if (ticket.getTicketId() == 0) {
switch (ticket.getTicketType()) {
case TicketInfo.RECEIPT_NORMAL:
          ticket.setTicketId(getNextTicketIndex().intValue());
        break;
case TicketInfo.RECEIPT_REFUND:
      ticket.setTicketId(getNextTicketRefundIndex().intValue());
    break;
case TicketInfo.RECEIPT_PAYMENT:
  ticket.setTicketId(getNextTicketPaymentIndex().intValue());
break;
default :
throw new BasicException();
}
}
new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE).exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,ticket.getId());
setString(2,ticket.getActiveCash());
setTimestamp(3,ticket.getDate());
try {
ByteArrayOutputStream o=new ByteArrayOutputStream();
ticket.getProperties().storeToXML(o,AppLocal.APP_NAME,"String_Node_Str");
setBytes(4,o.toByteArray());
}
 catch (IOException e) {
setBytes(4,null);
}
}
}
);
new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE).exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,ticket.getId());
setInt(2,ticket.getTicketType());
setInt(3,ticket.getTicketId());
setString(4,ticket.getUser().getId());
setString(5,ticket.getCustomerId());
}
}
);
SentenceExec ticketlineinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteBuilder.INSTANCE);
for (TicketLineInfo l : ticket.getLines()) {
ticketlineinsert.exec(l);
if (l.getProductID() != null) {
getStockDiaryInsert().exec(new Object[]{UUID.randomUUID().toString(),ticket.getDate(),l.getMultiply() < 0.0 ? MovementReason.IN_REFUND.getKey() : MovementReason.OUT_SALE.getKey(),location,l.getProductID(),new Double(-l.getMultiply()),new Double(l.getPrice())});
}
}
SentenceExec paymentinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE);
for (final PaymentInfo p : ticket.getPayments()) {
paymentinsert.exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,UUID.randomUUID().toString());
setString(2,ticket.getId());
setString(3,p.getName());
setDouble(4,p.getTotal());
setString(5,ticket.getTransactionID());
setBytes(6,(byte[])Formats.BYTEA.parseValue(ticket.getReturnMessage()));
}
}
);
if ("String_Node_Str".equals(p.getName()) || "String_Node_Str".equals(p.getName())) {
ticket.getCustomer().updateCurDebt(p.getTotal(),ticket.getDate());
getDebtUpdate().exec(new DataParams(){
public void writeValues() throws BasicException {
setDouble(1,ticket.getCustomer().getCurdebt());
setTimestamp(2,ticket.getCustomer().getCurdate());
setString(3,ticket.getCustomer().getId());
}
}
);
}
}
SentenceExec taxlinesinsert=new PreparedSentence(s,"String_Node_Str",SerializerWriteParams.INSTANCE);
if (ticket.getTaxes() != null) {
for (final TicketTaxInfo tickettax : ticket.getTaxes()) {
taxlinesinsert.exec(new DataParams(){
public void writeValues() throws BasicException {
setString(1,UUID.randomUUID().toString());
setString(2,ticket.getId());
setString(3,tickettax.getTaxInfo().getId());
setDouble(4,tickettax.getSubTotal());
setDouble(5,tickettax.getTax());
}
}
);
}
}
return null;
}
}
;
t.execute();
}