diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/XmlSerializer.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/XmlSerializer.java index 1a9866cae4477966ac501a810e77b493e3602003..1f519823757953c1eb2351e2c2a5c7eb57cb76f7 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/XmlSerializer.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/XmlSerializer.java @@ -20,7 +20,7 @@ import org.w3c.dom.Node; * type of the object to serialize */ public class XmlSerializer<T> { - + /** * Class of the object that DAO works on. */ @@ -93,6 +93,8 @@ public class XmlSerializer<T> { return (T) jaxbUnmarshaller.unmarshal(node); } catch (JAXBException e) { throw new SerializationException(e); + } catch (Exception e) { //the library can throw NPE sometimes... + throw new SerializationException(e); } } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java index dda935775b47a979b21017068adf90c8a6d5a156..125a040e3abb179b6ba23c47606569c20ff014a3 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java @@ -2,6 +2,9 @@ package lcsb.mapviewer.annotation.services; import java.io.IOException; +import javax.sql.rowset.serial.SerialException; + +import org.apache.commons.lang3.SerializationException; import org.apache.log4j.Logger; import org.w3c.dom.Node; @@ -100,16 +103,22 @@ public class MeSHParser extends CachableInterface implements IExternalService { String id = getIdentifier(meshID); Node meshNode = super.getCacheNode(id); if (meshNode != null && meshNode.hasChildNodes()) { - mesh = meshSerializer.xmlToObject(meshNode); - } else { + try { + mesh = meshSerializer.xmlToObject(meshNode); + } catch (SerializationException e) { + logger.warn("Problem with processing cached info about mesh: " + meshID); + mesh = null; + } + } + if (mesh == null) { try { mesh = getMeSHByIdFromDB(meshID); } catch (IOException e) { throw new AnnotatorException("Problem with accessing MeSH database", e); } - if (mesh != null) { - super.setCacheValue(id, this.meshSerializer.objectToString(mesh)); - } + } + if (mesh != null) { + super.setCacheValue(id, this.meshSerializer.objectToString(mesh)); } return mesh;