Discussion:
[e-lang] Patch for review: Fix CapTPReplacer NPE on a promise for null.
Kevin Reid
2011-08-12 16:37:18 UTC
Permalink
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 <***@switchb.org>
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/>
Mark S. Miller
2011-08-13 04:22:09 UTC
Permalink
yes, that looks good. Please commit. Thanks.
Post by Kevin Reid
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
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
http://www.eros-os.org/mailman/listinfo/e-lang
--
Cheers,
--MarkM
Loading...