Program: 99493
Project: 99493
Buggy source:
/** 
 * SysEx Code Index Number : 0x4, 0x5, 0x6, 0x7
 * @param cable 0-15
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
@SuppressWarnings("String_Node_Str") public void sendMidiSystemExclusive(int cable,byte[] systemExclusive){
  ByteArrayOutputStream transferDataStream=new ByteArrayOutputStream();
  for (int sysexIndex=0; sysexIndex < systemExclusive.length; sysexIndex+=3) {
    if ((sysexIndex + 3 < systemExclusive.length)) {
      transferDataStream.write((((cable & 0xf) << 4) | 0x4));
      transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
      transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
      transferDataStream.write(systemExclusive[sysexIndex + 2] & 0xff);
    }
 else {
switch (systemExclusive.length % 3) {
case 1:
        transferDataStream.write((((cable & 0xf) << 4) | 0x5));
      transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
    transferDataStream.write(0);
  transferDataStream.write(0);
break;
case 2:
transferDataStream.write((((cable & 0xf) << 4) | 0x6));
transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
transferDataStream.write(0);
break;
case 0:
transferDataStream.write((((cable & 0xf) << 4) | 0x7));
transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 2] & 0xff);
break;
}
}
}
byte[] buffer=transferDataStream.toByteArray();
synchronized (deviceConnection) {
if (usbRequest == null) {
usbRequest=new UsbRequest();
usbRequest.initialize(deviceConnection,outputEndpoint);
}
while (usbRequest.queue(ByteBuffer.wrap(buffer),buffer.length) == false) {
try {
Thread.sleep(1);
}
 catch (InterruptedException e) {
}
}
}
Log.d(Constants.TAG,"String_Node_Str" + buffer.length + "String_Node_Str"+ buffer.length+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * SysEx Code Index Number : 0x4, 0x5, 0x6, 0x7
 * @param cable 0-15
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
@SuppressWarnings("String_Node_Str") public void sendMidiSystemExclusive(int cable,byte[] systemExclusive){
  ByteArrayOutputStream transferDataStream=new ByteArrayOutputStream();
  for (int sysexIndex=0; sysexIndex < systemExclusive.length; sysexIndex+=3) {
    if ((sysexIndex + 3 < systemExclusive.length)) {
      transferDataStream.write((((cable & 0xf) << 4) | 0x4));
      transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
      transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
      transferDataStream.write(systemExclusive[sysexIndex + 2] & 0xff);
    }
 else {
switch (systemExclusive.length % 3) {
case 1:
        transferDataStream.write((((cable & 0xf) << 4) | 0x5));
      transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
    transferDataStream.write(0);
  transferDataStream.write(0);
break;
case 2:
transferDataStream.write((((cable & 0xf) << 4) | 0x6));
transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
transferDataStream.write(0);
break;
case 0:
transferDataStream.write((((cable & 0xf) << 4) | 0x7));
transferDataStream.write(systemExclusive[sysexIndex + 0] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 1] & 0xff);
transferDataStream.write(systemExclusive[sysexIndex + 2] & 0xff);
break;
}
}
}
byte[] buffer=transferDataStream.toByteArray();
synchronized (deviceConnection) {
if (usbRequest == null) {
usbRequest=new UsbRequest();
usbRequest.initialize(deviceConnection,outputEndpoint);
}
while (usbRequest.queue(ByteBuffer.wrap(buffer),buffer.length) == false) {
try {
Thread.sleep(1);
}
 catch (InterruptedException e) {
}
}
while (usbRequest.equals(deviceConnection.requestWait()) == false) {
try {
Thread.sleep(1);
}
 catch (InterruptedException e) {
}
}
}
Log.d(Constants.TAG,"String_Node_Str" + buffer.length + "String_Node_Str"+ buffer.length+ "String_Node_Str");
}