diff --git a/src/java/com/threerings/getdown/data/Application.java b/src/java/com/threerings/getdown/data/Application.java index fc8780d..19d3ad2 100644 --- a/src/java/com/threerings/getdown/data/Application.java +++ b/src/java/com/threerings/getdown/data/Application.java @@ -43,7 +43,6 @@ import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.net.URLConnection; import java.util.ArrayList; import java.util.HashMap; @@ -353,17 +352,19 @@ public class Application } /** - * Sets a cookie for a tracking URL if we have an appropriate property to fetch it from, - * an appropriate cookie name to assign, and the property is set to non-null. + * Returns the name of our tracking cookie or null if it was not set. */ - public void maybeSetTrackingCookie (URLConnection conn) + public String getTrackingCookieName () { - if (_trackingCookieName != null && _trackingCookieProperty != null) { - String val = System.getProperty(_trackingCookieProperty); - if (val != null) { - conn.setRequestProperty("Cookie", _trackingCookieName + "=" + val); - } - } + return _trackingCookieName; + } + + /** + * Returns the name of our tracking cookie system property or null if it was not set. + */ + public String getTrackingCookieProperty () + { + return _trackingCookieProperty; } /** diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index 9d2220a..1617e20 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -853,7 +853,17 @@ public abstract class Getdown extends Thread public void run () { try { HttpURLConnection ucon = (HttpURLConnection)_url.openConnection(); - _app.maybeSetTrackingCookie(ucon); + + // if we have a tracking cookie configured, configure the request with it + if (_app.getTrackingCookieName() != null && + _app.getTrackingCookieProperty() != null) { + String val = System.getProperty(_app.getTrackingCookieProperty()); + if (val != null) { + ucon.setRequestProperty("Cookie", _app.getTrackingCookieName() + "=" + val); + } + } + + // now request our tracking URL and ensure that we get a non-error response ucon.connect(); try { if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { @@ -863,6 +873,7 @@ public abstract class Getdown extends Thread } finally { ucon.disconnect(); } + } catch (IOException ioe) { Log.warning("Failed to report tracking event [url=" + _url + ", error=" + ioe + "].");