FHIR Chat · issue in generated core · hapi

Stream: hapi

Topic: issue in generated core


view this post on Zulip Grahame Grieve (Jul 20 2016 at 21:51):

@James Agnew, a question about our generated code:

view this post on Zulip Grahame Grieve (Jul 20 2016 at 21:52):

        public Reference getSourceReference() throws FHIRException { 
          if (!(this.source instanceof Reference))
            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.source.getClass().getName()+" was encountered");
          return (Reference) this.source;
        }

view this post on Zulip Grahame Grieve (Jul 20 2016 at 21:52):

this will result in an NPE if this.source == null, which is obviously no good.

view this post on Zulip Grahame Grieve (Jul 20 2016 at 21:52):

but what should it do in that case?

view this post on Zulip Grahame Grieve (Jul 24 2016 at 22:59):

@James Agnew - ping on this subject...

view this post on Zulip James Agnew (Jul 24 2016 at 23:09):

Sorry! Hopelessly behind on messages right now... Agreed that seems like a bug. We should probably have something like

if (this.source != null && !(this.source instanceof Reference)) {

view this post on Zulip James Agnew (Jul 24 2016 at 23:10):

I think returning null is sensible behaviour in that case.

view this post on Zulip Grahame Grieve (Jul 24 2016 at 23:10):

ok will do.

view this post on Zulip Grahame Grieve (Jul 24 2016 at 23:11):

thanks


Last updated: Apr 12 2022 at 19:14 UTC