Skip to content

Commit

Permalink
Added some checks for null specification references. Code is now more…
Browse files Browse the repository at this point in the history
… robust to ill-formed dictionary elements
  • Loading branch information
rajarshi committed Apr 10, 2012
1 parent f2080e1 commit faa5404
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/org/openscience/cdk/qsar/DescriptorEngine.java
Expand Up @@ -23,7 +23,6 @@
import nu.xom.Attribute;
import nu.xom.Element;
import nu.xom.Elements;

import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand Down Expand Up @@ -411,8 +410,12 @@ public String getDictionaryDefinition(String identifier) {
Entry[] dictEntries = dict.getEntries();

String specRef = getSpecRef(identifier);
String definition = null;
if (specRef == null) {
logger.error("Cannot determine specification for id: ", identifier);
return "";
}

String definition = null;
for (Entry dictEntry : dictEntries) {
if (!dictEntry.getClassName().equals("Descriptor")) continue;
if (dictEntry.getID().equals(specRef.toLowerCase())) {
Expand Down Expand Up @@ -448,8 +451,12 @@ public String getDictionaryDefinition(DescriptorSpecification descriptorSpecific
public String getDictionaryTitle(String identifier) {
Entry[] dictEntries = dict.getEntries();
String specRef = getSpecRef(identifier);
String title = null;
if (specRef == null) {
logger.error("Cannot determine specification for id: ", identifier);
return "";
}

String title = null;
for (Entry dictEntry : dictEntries) {
if (!dictEntry.getClassName().equals("Descriptor")) continue;
if (dictEntry.getID().equals(specRef.toLowerCase())) {
Expand Down

0 comments on commit faa5404

Please sign in to comment.