From: <nik...@us...> - 2015-12-11 13:43:16
|
Revision: 2448 http://sourceforge.net/p/jsbml/code/2448 Author: niko-rodrigue Date: 2015-12-11 13:43:13 +0000 (Fri, 11 Dec 2015) Log Message: ----------- corrected several potential NullPointerExceptions that could occur during the cloning of an SBMLDocument Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/SBMLDocument.java Modified: trunk/core/src/org/sbml/jsbml/SBMLDocument.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2015-12-11 13:38:49 UTC (rev 2447) +++ trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2015-12-11 13:43:13 UTC (rev 2448) @@ -117,7 +117,7 @@ /** * logger used to print messages */ - private transient Logger logger = Logger.getLogger(getClass()); + private static final transient Logger logger = Logger.getLogger(SBMLDocument.class); /** * Stores all the meta identifiers within this {@link SBMLDocument} to avoid @@ -489,7 +489,8 @@ } metaIds.put(sbase.getMetaId(), sbase); - if (logger.isDebugEnabled()) { + // logger can be null during cloning apparently + if (logger != null && logger.isDebugEnabled()) { logger.debug("SBMLDocument - #collectMetaIds - node = '" + sbase + "'"); } } @@ -513,6 +514,11 @@ * @return */ public boolean containsMetaId(String metaId) { + + if (mappingFromMetaId2SBase == null) { + mappingFromMetaId2SBase = new HashMap<String, SBase>(); + } + return mappingFromMetaId2SBase.containsKey(metaId); } @@ -1162,6 +1168,11 @@ * */ boolean registerMetaId(SBase sbase, boolean add) { + + if (mappingFromMetaId2SBase == null) { + mappingFromMetaId2SBase = new HashMap<String, SBase>(); + } + if (sbase.isSetMetaId()) { if (add) { // We should call checkMetaid if we want to throw IllegalArgumentException here when metaid already present This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |