diff --git a/sensorhub-service-consys/src/main/java/org/sensorhub/impl/service/consys/sensorml/SmlProcessBindingSmlXml.java b/sensorhub-service-consys/src/main/java/org/sensorhub/impl/service/consys/sensorml/SmlProcessBindingSmlXml.java index a69f03a45..757e26faf 100644 --- a/sensorhub-service-consys/src/main/java/org/sensorhub/impl/service/consys/sensorml/SmlProcessBindingSmlXml.java +++ b/sensorhub-service-consys/src/main/java/org/sensorhub/impl/service/consys/sensorml/SmlProcessBindingSmlXml.java @@ -74,7 +74,25 @@ public V deserialize() throws IOException if (!xmlReader.hasNext()) return null; - xmlReader.nextTag(); + try + { + xmlReader.nextTag(); + } + catch (XMLStreamException e) + { + // If the xmlReader is not advanced to END_OF_DOCUMENT + // before calling nextTag(), hasNext() above will still + // return true and nextTag() will fail. The best + // heuristic of this situation we have is to catch the + // exception and call hasNext. If so, that just means + // there was nothing (except maybe whitespace and + // comments) after the previous document, and that is + // not an exception. + if (!xmlReader.hasNext()) + return null; + + throw e; + } var sml = smlBindings.readDescribedObject(xmlReader); if (sml instanceof Deployment)