Program: 69210
Project: 69210
Buggy source:
public boolean _load(File file,ProgressHandler handler){
  this.file=file;
  handler.setProgress(String.format(Messages.getString("String_Node_Str"),file),-1);
  SAXParserFactory factory=SAXParserFactory.newInstance();
  try {
    SAXParser parser=factory.newSAXParser();
    parser.parse(file,new DefaultHandler(){
      private HashMap<String,Rom> roms_bycrc=new HashMap<>();
      private boolean in_softwares_list=false;
      private boolean in_software=false;
      private boolean in_machine=false;
      private boolean in_description=false;
      private boolean in_header=false;
      private SoftwareList curr_software_list=null;
      private Software curr_software=null;
      private Machine curr_machine=null;
      private Rom curr_rom=null;
      private Disk curr_disk=null;
      private String curr_tag;
      @Override public void startElement(      String uri,      String localName,      String qName,      Attributes attributes) throws SAXException {
        curr_tag=qName;
        if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
          for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
              build=attributes.getValue(i);
          }
        }
      }
 else       if (qName.equals("String_Node_Str")) {
        in_header=true;
      }
 else       if (qName.equals("String_Node_Str")) {
        in_softwares_list=true;
        curr_software_list=new SoftwareList();
        for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
            curr_software_list.name=attributes.getValue(i);
          software_list_byname.put(curr_software_list.name,curr_software_list);
        break;
    }
  }
}
 else if (qName.equals("String_Node_Str")) {
  in_software=true;
  curr_software=new Software();
  for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
      curr_software.name=attributes.getValue(i);
    break;
case "String_Node_Str":
  curr_software.cloneof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_software.supported=Software.Supported.valueOf(attributes.getValue(i));
break;
}
}
}
 else if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
in_machine=true;
curr_machine=new Machine();
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_machine.name=attributes.getValue(i);
machines_byname.put(curr_machine.name,curr_machine);
break;
case "String_Node_Str":
curr_machine.romof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.cloneof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.sampleof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.isbios=BooleanUtils.toBoolean(attributes.getValue(i));
break;
case "String_Node_Str":
curr_machine.ismechanical=BooleanUtils.toBoolean(attributes.getValue(i));
break;
case "String_Node_Str":
curr_machine.isdevice=BooleanUtils.toBoolean(attributes.getValue(i));
break;
}
}
}
 else if (qName.equals("String_Node_Str") && (in_machine || in_software || in_softwares_list)) {
in_description=true;
}
 else if (qName.equals("String_Node_Str")) {
if (in_machine || in_software) {
curr_rom=new Rom(in_machine ? curr_machine : curr_software);
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_rom.setName(attributes.getValue(i));
break;
case "String_Node_Str":
curr_rom.size=Long.decode(attributes.getValue(i));
break;
case "String_Node_Str":
curr_rom.crc=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.sha1=attributes.getValue(i);
sha1_roms=true;
break;
case "String_Node_Str":
curr_rom.md5=attributes.getValue(i);
md5_roms=true;
break;
case "String_Node_Str":
curr_rom.merge=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.bios=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.status=Entity.Status.valueOf(attributes.getValue(i));
break;
}
}
}
}
 else if (qName.equals("String_Node_Str")) {
if (in_machine || in_software) {
curr_disk=new Disk(in_machine ? curr_machine : curr_software);
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_disk.setName(attributes.getValue(i));
break;
case "String_Node_Str":
curr_disk.sha1=attributes.getValue(i);
sha1_disks=true;
break;
case "String_Node_Str":
curr_disk.md5=attributes.getValue(i);
md5_disks=true;
break;
case "String_Node_Str":
curr_disk.merge=attributes.getValue(i);
break;
case "String_Node_Str":
curr_disk.status=Entity.Status.valueOf(attributes.getValue(i));
break;
}
}
}
}
}
@Override public void endElement(String uri,String localName,String qName) throws SAXException {
if (qName.equals("String_Node_Str")) {
in_header=false;
}
 else if (qName.equals("String_Node_Str")) {
software_lists.add(curr_software_list);
softwares_list_cnt++;
in_softwares_list=false;
}
 else if (qName.equals("String_Node_Str")) {
curr_software_list.add(curr_software);
softwares_cnt++;
in_software=false;
handler.setProgress(String.format(Messages.getString("String_Node_Str"),softwares_cnt,roms_cnt));
if (handler.isCancel()) throw new BreakException();
}
 else if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
machines.add(curr_machine);
machines_cnt++;
in_machine=false;
handler.setProgress(String.format(Messages.getString("String_Node_Str"),machines_cnt,roms_cnt));
if (handler.isCancel()) throw new BreakException();
}
 else if (qName.equals("String_Node_Str")) {
(in_machine ? curr_machine : curr_software).roms.add(curr_rom);
roms_cnt++;
if (curr_rom.crc != null) {
Rom old_rom=roms_bycrc.put(curr_rom.crc,curr_rom);
if (old_rom != null) {
if (old_rom.sha1 != null && curr_rom.sha1 != null) if (!old_rom.equals(curr_rom)) suspicious_crc.add(curr_rom.crc);
if (old_rom.md5 != null && curr_rom.md5 != null) if (!old_rom.equals(curr_rom)) suspicious_crc.add(curr_rom.crc);
}
}
}
 else if (qName.equals("String_Node_Str")) {
(in_machine ? curr_machine : curr_software).disks.add(curr_disk);
disks_cnt++;
}
 else if (qName.equals("String_Node_Str") && (in_machine || in_software || in_softwares_list)) {
in_description=false;
}
}
@Override public void characters(char[] ch,int start,int length) throws SAXException {
if (in_description) {
if (in_machine) curr_machine.description.append(ch,start,length);
 else if (in_software) curr_software.description.append(ch,start,length);
 else if (in_softwares_list) curr_software_list.description.append(ch,start,length);
}
 else if (in_header) {
if (!header.containsKey(curr_tag)) header.put(curr_tag,new StringBuffer());
header.get(curr_tag).append(ch,start,length);
}
}
}
);
handler.setProgress(Messages.getString("String_Node_Str"),-1);
machines.forEach(machine -> {
if (machine.romof != null) {
machine.parent=machines_byname.get(machine.romof);
if (machine.parent != null) {
if (!machine.getParent().isbios) machine.parent.clones.put(machine.name,machine);
}
}
}
);
software_lists.forEach(software_list -> {
software_list.softwares.forEach(software -> {
if (software.cloneof != null) {
software.parent=software_list.softwares_byname.get(software.cloneof);
if (software.parent != null) software.parent.clones.put(software.name,software);
}
}
);
}
);
handler.setProgress(Messages.getString("String_Node_Str"),-1);
save();
return true;
}
 catch (ParserConfigurationException|SAXException e) {
Log.err("String_Node_Str",e);
}
catch (IOException e) {
Log.err("String_Node_Str",e);
}
catch (BreakException e) {
return false;
}
catch (Throwable e) {
Log.err("String_Node_Str",e);
}
return false;
}

Fixed version (ground truth):
public boolean _load(File file,ProgressHandler handler){
  this.file=file;
  handler.setProgress(String.format(Messages.getString("String_Node_Str"),file),-1);
  SAXParserFactory factory=SAXParserFactory.newInstance();
  try {
    SAXParser parser=factory.newSAXParser();
    parser.parse(file,new DefaultHandler(){
      private HashMap<String,Rom> roms_bycrc=new HashMap<>();
      private boolean in_softwares_list=false;
      private boolean in_software=false;
      private boolean in_machine=false;
      private boolean in_description=false;
      private boolean in_header=false;
      private SoftwareList curr_software_list=null;
      private Software curr_software=null;
      private Machine curr_machine=null;
      private Rom curr_rom=null;
      private Disk curr_disk=null;
      private String curr_tag;
      @Override public void startElement(      String uri,      String localName,      String qName,      Attributes attributes) throws SAXException {
        curr_tag=qName;
        if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
          for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
              build=attributes.getValue(i);
          }
        }
      }
 else       if (qName.equals("String_Node_Str")) {
        in_header=true;
      }
 else       if (qName.equals("String_Node_Str")) {
        in_softwares_list=true;
        curr_software_list=new SoftwareList();
        for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
            curr_software_list.name=attributes.getValue(i);
          software_list_byname.put(curr_software_list.name,curr_software_list);
        break;
    }
  }
}
 else if (qName.equals("String_Node_Str")) {
  in_software=true;
  curr_software=new Software();
  for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
      curr_software.name=attributes.getValue(i);
    break;
case "String_Node_Str":
  curr_software.cloneof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_software.supported=Software.Supported.valueOf(attributes.getValue(i));
break;
}
}
}
 else if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
in_machine=true;
curr_machine=new Machine();
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_machine.name=attributes.getValue(i);
machines_byname.put(curr_machine.name,curr_machine);
break;
case "String_Node_Str":
curr_machine.romof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.cloneof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.sampleof=attributes.getValue(i);
break;
case "String_Node_Str":
curr_machine.isbios=BooleanUtils.toBoolean(attributes.getValue(i));
break;
case "String_Node_Str":
curr_machine.ismechanical=BooleanUtils.toBoolean(attributes.getValue(i));
break;
case "String_Node_Str":
curr_machine.isdevice=BooleanUtils.toBoolean(attributes.getValue(i));
break;
}
}
}
 else if (qName.equals("String_Node_Str") && (in_machine || in_software || in_softwares_list)) {
in_description=true;
}
 else if (qName.equals("String_Node_Str")) {
if (in_machine || in_software) {
curr_rom=new Rom(in_machine ? curr_machine : curr_software);
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_rom.setName(attributes.getValue(i));
break;
case "String_Node_Str":
curr_rom.size=Long.decode(attributes.getValue(i));
break;
case "String_Node_Str":
curr_rom.crc=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.sha1=attributes.getValue(i);
sha1_roms=true;
break;
case "String_Node_Str":
curr_rom.md5=attributes.getValue(i);
md5_roms=true;
break;
case "String_Node_Str":
curr_rom.merge=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.bios=attributes.getValue(i);
break;
case "String_Node_Str":
curr_rom.status=Entity.Status.valueOf(attributes.getValue(i));
break;
}
}
}
}
 else if (qName.equals("String_Node_Str")) {
if (in_machine || in_software) {
curr_disk=new Disk(in_machine ? curr_machine : curr_software);
for (int i=0; i < attributes.getLength(); i++) {
switch (attributes.getQName(i)) {
case "String_Node_Str":
curr_disk.setName(attributes.getValue(i));
break;
case "String_Node_Str":
curr_disk.sha1=attributes.getValue(i);
sha1_disks=true;
break;
case "String_Node_Str":
curr_disk.md5=attributes.getValue(i);
md5_disks=true;
break;
case "String_Node_Str":
curr_disk.merge=attributes.getValue(i);
break;
case "String_Node_Str":
curr_disk.status=Entity.Status.valueOf(attributes.getValue(i));
break;
}
}
}
}
}
@Override public void endElement(String uri,String localName,String qName) throws SAXException {
if (qName.equals("String_Node_Str")) {
in_header=false;
}
 else if (qName.equals("String_Node_Str")) {
software_lists.add(curr_software_list);
softwares_list_cnt++;
in_softwares_list=false;
}
 else if (qName.equals("String_Node_Str")) {
curr_software_list.add(curr_software);
softwares_cnt++;
in_software=false;
handler.setProgress(String.format(Messages.getString("String_Node_Str"),softwares_cnt,roms_cnt));
if (handler.isCancel()) throw new BreakException();
}
 else if (qName.equals("String_Node_Str") || qName.equals("String_Node_Str")) {
machines.add(curr_machine);
machines_cnt++;
in_machine=false;
handler.setProgress(String.format(Messages.getString("String_Node_Str"),machines_cnt,roms_cnt));
if (handler.isCancel()) throw new BreakException();
}
 else if (qName.equals("String_Node_Str")) {
if (curr_rom.getName() != null) {
(in_machine ? curr_machine : curr_software).roms.add(curr_rom);
roms_cnt++;
if (curr_rom.crc != null) {
Rom old_rom=roms_bycrc.put(curr_rom.crc,curr_rom);
if (old_rom != null) {
if (old_rom.sha1 != null && curr_rom.sha1 != null) if (!old_rom.equals(curr_rom)) suspicious_crc.add(curr_rom.crc);
if (old_rom.md5 != null && curr_rom.md5 != null) if (!old_rom.equals(curr_rom)) suspicious_crc.add(curr_rom.crc);
}
}
}
}
 else if (qName.equals("String_Node_Str")) {
if (curr_disk.getName() != null) {
(in_machine ? curr_machine : curr_software).disks.add(curr_disk);
disks_cnt++;
}
}
 else if (qName.equals("String_Node_Str") && (in_machine || in_software || in_softwares_list)) {
in_description=false;
}
}
@Override public void characters(char[] ch,int start,int length) throws SAXException {
if (in_description) {
if (in_machine) curr_machine.description.append(ch,start,length);
 else if (in_software) curr_software.description.append(ch,start,length);
 else if (in_softwares_list) curr_software_list.description.append(ch,start,length);
}
 else if (in_header) {
if (!header.containsKey(curr_tag)) header.put(curr_tag,new StringBuffer());
header.get(curr_tag).append(ch,start,length);
}
}
}
);
handler.setProgress(Messages.getString("String_Node_Str"),-1);
machines.forEach(machine -> {
if (machine.romof != null) {
machine.parent=machines_byname.get(machine.romof);
if (machine.parent != null) {
if (!machine.getParent().isbios) machine.parent.clones.put(machine.name,machine);
}
}
}
);
software_lists.forEach(software_list -> {
software_list.softwares.forEach(software -> {
if (software.cloneof != null) {
software.parent=software_list.softwares_byname.get(software.cloneof);
if (software.parent != null) software.parent.clones.put(software.name,software);
}
}
);
}
);
handler.setProgress(Messages.getString("String_Node_Str"),-1);
save();
return true;
}
 catch (ParserConfigurationException|SAXException e) {
Log.err("String_Node_Str",e);
}
catch (IOException e) {
Log.err("String_Node_Str",e);
}
catch (BreakException e) {
return false;
}
catch (Throwable e) {
Log.err("String_Node_Str",e);
}
return false;
}