From 5b68088b7cc820c59de768bb5e71a3d5ab02286a Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 18 Jun 2004 17:41:39 +0000 Subject: [PATCH] Download the properties file ourselves before handing it to Java to parse into a properties object so that we can log the text if Java chokes. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3034 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/resource/ResourceManager.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index 4e79a46fc..88cabb127 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -1,11 +1,13 @@ // -// $Id: ResourceManager.java,v 1.41 2004/06/15 18:25:13 mdb Exp $ +// $Id: ResourceManager.java,v 1.42 2004/06/18 17:41:39 mdb Exp $ package com.threerings.resource; import java.awt.EventQueue; import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -26,6 +28,8 @@ import javax.imageio.stream.FileImageInputStream; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.MemoryCacheImageInputStream; +import org.apache.commons.io.StreamUtils; + import com.samskivert.util.ResultListener; import com.samskivert.util.StringUtil; @@ -281,7 +285,6 @@ public class ResourceManager try { if (configPath != null) { curl = new URL(_rurl, configPath); - config.load(curl.openStream()); } } catch (MalformedURLException mue) { @@ -290,11 +293,21 @@ public class ResourceManager String errmsg = "Invalid config url [resourceURL=" + _rurl + ", configPath=" + configPath + "]"; throw new IOException(errmsg); + } + + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + try { + if (curl != null) { + // download the properties file into a buffer + StreamUtils.pipe(curl.openStream(), bout); + config.load(new ByteArrayInputStream(bout.toByteArray())); + } } catch (Exception e) { Log.warning("Unable to load resource mgr properties " + "[resourceURL=" + _rurl + ", configPath=" + configPath + ", error=" + e + "]."); + Log.warning("Bogus properties: " + bout.toString("UTF-8")); Log.logStackTrace(e); String errmsg = "Unable to load resource manager config " + "[resourceURL=" + _rurl + ", configPath=" + configPath + "]";