Re: Patch for review: Fix CapTPReplacer NPE on a promise for null.
"Mark S. Miller" <[email protected]> Fri, 12 Aug 2011 21:22:09 -0700
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <CABHxS9hQLfmARWkWEdYBksWk=RQjvfJzpkT-czJrQZa13go_rw@mail.gmail.com> |
yes, that looks good. Please commit. Thanks. On Fri, Aug 12, 2011 at 9:37 AM, Kevin Reid <kpreid-M/[email protected]> wrote: > I'd like your opinion on this before I commit it to SVN. I'm not an expert > on the JOSS CapTP components, but this bug and fix seemed pretty clear. > > commit b113b90299f16ef65c8d6e55b2f6c5e2da966e14 > Author: Kevin Reid <kpreid-M/[email protected]> > Date: Fri Aug 12 09:32:11 2011 > > Fix CapTPReplacer NPE on a promise for null. > > If CapTPReplacer met a promise resolved to null, it would crash with > NullPointerException when trying to check for a writeReplace method. Fix by > adding a shortcut around that code for null. > > diff --git a/src/jsrc/net/captp/jcomm/CapTPReplacer.java > b/src/jsrc/net/captp/jcomm/CapTPReplacer.java > index 53487c0..d8191a7 100644 > --- a/src/jsrc/net/captp/jcomm/CapTPReplacer.java > +++ b/src/jsrc/net/captp/jcomm/CapTPReplacer.java > @@ -54,7 +54,10 @@ class CapTPReplacer extends Replacer { > */ > public Object substitute(Object ref) { > Object resolvedRef = Ref.resolution(ref); > - if (resolvedRef != ref) { > + if (resolvedRef == null) { > + // Next branch would NullPointerException, so don't try. > + ref = resolvedRef; > + } else if (resolvedRef != ref) { > /* Java serialization has given the original ref the chance to > * writeReplace itself, but not the target. Do that now. > */ > > -- > Kevin Reid <http://switchb.org/kpreid/> > > > _______________________________________________ > e-lang mailing list > [email protected] > http://www.eros-os.org/mailman/listinfo/e-lang > -- Cheers, --MarkM _______________________________________________ e-lang mailing list [email protected] http://www.eros-os.org/mailman/listinfo/e-lang