Is this a bug?

Jun 1, 2011 at 4:40 PM

Hi.

In testing my app, I came across this case. I went to my account on the HealthVault web interface (development version) and added a weight reading manually. Then when my app was retrieving the data from HealthVault, the library threw an Exception:

java.lang.NullPointerException
	at com.microsoft.hsg.thing.oxm.jaxb.dates.DateTime.toCalendar(DateTime.java:177)
	at com.prodea.osgi.hv.MedicalRecordFactory.getMillis(MedicalRecordFactory.java:84)
	at com.prodea.osgi.hv.MedicalRecordFactory.builder(MedicalRecordFactory.java:61)
	at com.prodea.osgi.hv.HealthVaultService.getRecords(HealthVaultService.java:240)
	at com.prodea.osgi.apps.ehealth.EHRSynchronizer.syncEhrWithLocalForAdditions(EHRSynchronizer.java:191)
	at com.prodea.osgi.apps.ehealth.EHealth.syncWithEhr(EHealth.java:239)
	at com.prodea.osgi.apps.ehealth.EHealth.access$1(EHealth.java:217)
	at com.prodea.osgi.apps.ehealth.EHealth$2.run(EHealth.java:207)
	at java.lang.Thread.run(Thread.java:619)

When I looked at the logs, here is the portion of the data that is causing problem:

      <thing>
        <thing-id version-stamp="b3857569-2908-46a8-b47b-f41316e8948c">
        a183db03-8acc-41a8-9934-0eda3c4f6a6a</thing-id>
        <type-id name="Weight Measurement">
        3d34d87e-7fc1-4153-800f-f56592cb0d17</type-id>
        <thing-state>Active</thing-state>
        <flags>0</flags>
        <eff-date>2011-06-01T11:26:00</eff-date>
        <created>
          <timestamp>2011-06-01T16:27:16.113Z</timestamp>
          <app-id name="Microsoft Health Explorer">
          9ca84d74-1473-471d-940f-2699cb7198df</app-id>
          <person-id name="Ali Naddaf">
          27592dcd-8dd6-4f69-94ed-434de02e7f81</person-id>
          <access-avenue>Online</access-avenue>
          <audit-action>Created</audit-action>
        </created>
        <updated>
          <timestamp>2011-06-01T16:27:16.113Z</timestamp>
          <app-id name="Microsoft Health Explorer">
          9ca84d74-1473-471d-940f-2699cb7198df</app-id>
          <person-id name="Ali Naddaf">
          27592dcd-8dd6-4f69-94ed-434de02e7f81</person-id>
          <access-avenue>Online</access-avenue>
          <audit-action>Created</audit-action>
        </updated>
        <data-xml>
          <weight>
            <when>
              <date>
                <y>2011</y>
                <m>6</m>
                <d>1</d>
              </date>
              <time>
                <h>11</h>
                <m>26</m>
              </time>
            </when>
            <value>
              <kg>79.832257121766233</kg>
              <display units="pounds" units-code="lb">176</display>
            </value>
          </weight>
          <common />
        </data-xml>
      </thing>

Here, the <s/> sub-element in the <time/> element is missing and that is where the library is throwing the exception. Is this a bug?

 

Many thanks

Ali.

Coordinator
Jun 2, 2011 at 5:46 AM

Thanks Ali.  I added to from/toCalendar methods to the Date objects as convenience methods but clearly didn't take the optional nature of the fields properly into account.  I'll fix that straight away.

--Rob