Thread: Java Webservice Bug

Started: 2014-05-07 00:48:20
Last activity: 2014-05-07 15:35:24
Topics: Web Services
Benjamin Sick
2014-05-07 00:48:20
Hello,

I discovered a bug in the IRIS webservice Java API library if the
endDate of a station is not set.

This happens e.g. with the following query on the Geofon FDSN server:
http://geofon.gfz-potsdam.de/fdsnws/station/1/query?net=GE&sta=STU&cha=BHZ&loc=--&starttime=2014-04-10T00:00:00&endtime=2014-04-10T00:10:00&level=channel

Channel part of output from Geofon:
<Channel code="BHZ" startDate="2000-01-01T00:00:00"
restrictedStatus="open" locationCode="">


The IRIS webservice returns a endDate with year 2599:
http://service.iris.edu/fdsnws/station/1/query?net=GE&sta=STU&cha=BHZ&loc=--&starttime=2014-04-10T00:00:00&endtime=2014-04-10T00:10:00&level=channel

Channel part of output from IRIS:
<Channel locationCode=" " startDate="2000-01-01T00:00:00"
restrictedStatus="open" endDate="2599-12-31T23:59:59" code="BHZ">

The problem is, that later in the class
edu.iris.dmc.extensions.entities.MetaData, the method toString() calls
SimpleDateFormat.format(endDate) where endDate is null which raises a
NullPointerException.

A simple fix would be to replace:
sb.append(sdf.format(startDate) + "," + sdf.format(endDate) + "\n");

With:
if (startDate != null) {
sb.append(sdf.format(startDate));
if (endDate != null) {
sb.append(",");
}
}
if (endDate != null) {
sb.append(sdf.format(endDate));
}
sb.append("\n");

The XML schema of FDSN does not require the endDate to be set (thanks
to Andres Heinloo for that):
$ xmllint --schema
http://www.fdsn.org/xml/station/fdsn-station-1.0.xsd
'http://geofon.gfz-potsdam.de/fdsnws/station/1/query?net=GE&sta=STU&cha=BHZ&loc=--&starttime=2014-04-10T00:00:00&endtime=2014-04-10T00:10:00&level=channel'
--noout
http://geofon.gfz-potsdam.de/fdsnws/station/1/query?net=GE&sta=STU&cha=BHZ&loc=--&starttime=2014-04-10T00:00:00&endtime=2014-04-10T00:10:00&level=channel
validates


Best Regards,
Benjamin Sick

--
Dipl.-Ing. Benjamin Sick
Institut für Geophysik
Universität Stuttgart

Email: benjamin.sick<at>geophys.uni-stuttgart.de
Website: http://www.geophys.uni-stuttgart.de/mitarbeiter/sick_benjamin.html
Phone: +49 711 685-87422
Fax: +49 711 685-87401


08:14:06 v.22510d55