From 54d3bb6496eba72d4d90a2977d3f1c194c40efbc Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 12 Sep 2006 01:09:01 +0000 Subject: [PATCH] Missed a spot where getStreamer() was called which motivated further changing around of the interface (I wanted to automatically call getStreamerClass() for the caller but that turns out not to be possible when unstreaming so fuck it). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4373 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/io/ObjectOutputStream.java | 9 ++++----- src/java/com/threerings/io/Streamer.java | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/io/ObjectOutputStream.java b/src/java/com/threerings/io/ObjectOutputStream.java index 25e26426c..31e4e1a8e 100644 --- a/src/java/com/threerings/io/ObjectOutputStream.java +++ b/src/java/com/threerings/io/ObjectOutputStream.java @@ -93,16 +93,14 @@ public class ObjectOutputStream extends DataOutputStream _classmap = new HashMap(); } - // otherwise, look up the class mapping record (if the target class is - // an enum, convert it from its potentially enum-value specific class - // to the main class for that enum) + // otherwise, look up the class mapping record Class sclass = Streamer.getStreamerClass(object); ClassMapping cmap = _classmap.get(sclass); // create a class mapping for this class if we've not got one if (cmap == null) { // create a streamer instance and assign a code to this class - Streamer streamer = Streamer.getStreamer(object); + Streamer streamer = Streamer.getStreamer(sclass); // we specifically do not inline the getStreamer() call // into the ClassMapping constructor because we want to be // sure not to call _nextCode++ if getStreamer() throws an @@ -148,7 +146,8 @@ public class ObjectOutputStream extends DataOutputStream public void writeBareObject (Object object) throws IOException { - writeBareObject(object, Streamer.getStreamer(object), true); + writeBareObject(object, Streamer.getStreamer( + Streamer.getStreamerClass(object)), true); } /** diff --git a/src/java/com/threerings/io/Streamer.java b/src/java/com/threerings/io/Streamer.java index 04537bd02..775afaee3 100644 --- a/src/java/com/threerings/io/Streamer.java +++ b/src/java/com/threerings/io/Streamer.java @@ -98,11 +98,15 @@ public class Streamer * are shared among all {@link ObjectInputStream}s and {@link * ObjectOutputStream}s. * + * @param target the class that is desired to be streamed. This should be + * the result of a call to {@link #getStreamerClass} if the caller has an + * instance they wish to stream. + * * @throws IOException when a streamer is requested for an object that * does not implement {@link Streamable} and is not one of the basic * object types (@see {@link ObjectOutputStream}). */ - public synchronized static Streamer getStreamer (Object object) + public synchronized static Streamer getStreamer (final Class target) throws IOException { // if we have not yet initialized ourselves, do so now @@ -110,11 +114,11 @@ public class Streamer createStreamers(); } - final Class target = getStreamerClass(object); Streamer stream = _streamers.get(target); if (stream == null) { // make sure this is a streamable class if (!isStreamable(target)) { + Thread.dumpStack(); throw new IOException("Requested to stream invalid class '" + target.getName() + "'"); }