Details about the known misuse from the MUBench dataset.
Description:
If the zargo file to be loaded contains no .argo file, this method will throw an exception at line 261.
Fix Description:
Check that the iterator contains a file to fix this.
Violation Types:
missing/condition/value_or_state
In File:
org/argouml/persistence/ZargoFilePersister.java
In Method:
loadFromZargo(File, ProgressMgr)
Code with Misuse:
class ZargoFilePersister {
private Project loadFromZargo(File file, ProgressMgr progressMgr)
throws OpenException {
Project p = ProjectFactory.getInstance().createProject(file.toURI());
try {
progressMgr.nextPhase();
// Load .argo project descriptor
ArgoParser parser = new ArgoParser();
String argoEntry = getEntryNames(file, ".argo").iterator().next();
parser.readProject(p, new InputSource(makeZipEntryUrl(toURL(file),
argoEntry).toExternalForm()));
List memberList = parser.getMemberList();
LOG.info(memberList.size() + " members");
// Load .xmi file before any PGML files
// FIXME: the following is loading the model before anything else.
// Due to the Zargo containing the profiles, currently we have
// removed this hack in UmlFilePersister and I think it should be
// removed from here also.
String xmiEntry = getEntryNames(file, ".xmi").iterator().next();
MemberFilePersister persister = getMemberFilePersister("xmi");
persister.load(p, makeZipEntryUrl(toURL(file), xmiEntry));
// Load the rest
List<String> entries = getEntryNames(file, null);
for (String name : entries) {
String ext = name.substring(name.lastIndexOf('.') + 1);
if (!"argo".equals(ext) && !"xmi".equals(ext)) {
persister = getMemberFilePersister(ext);
LOG.info("Loading member with "
+ persister.getClass().getName());
persister.load(p, openZipEntry(toURL(file), name));
}
}
progressMgr.nextPhase();
ThreadUtils.checkIfInterrupted();
p.postLoad();
return p;
} catch (InterruptedException e) {
return null;
} catch (MalformedURLException e) {
throw new OpenException(e);
} catch (IOException e) {
throw new OpenException(e);
} catch (SAXException e) {
throw new OpenException(e);
}
}
}