Patch for review: Fix CapTPReplacer NPE on a promise for null.
Kevin Reid <kpreid-M/[email protected]> Fri, 12 Aug 2011 09:37:18 -0700
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
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/>