Whitespace

This commit is contained in:
Dave Hoover
2010-11-30 01:06:20 +00:00
parent 11b2317d2a
commit da3d23a973
3 changed files with 53 additions and 67 deletions
@@ -302,8 +302,8 @@ public class Application
public Resource getPatchResource (String auxgroup) public Resource getPatchResource (String auxgroup)
{ {
if (_targetVersion <= _version) { if (_targetVersion <= _version) {
log.warning("Requested patch resource for up-to-date or non-versioned application " + log.warning("Requested patch resource for up-to-date or non-versioned application",
"[cvers=" + _version + ", tvers=" + _targetVersion + "]."); "cvers", _version, "tvers", _targetVersion);
return null; return null;
} }
@@ -313,9 +313,8 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), pfile); URL remote = new URL(createVAppBase(_targetVersion), pfile);
return new Resource(pfile, remote, getLocalPath(pfile), false); return new Resource(pfile, remote, getLocalPath(pfile), false);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to create patch resource path [pfile=" + pfile + log.warning("Failed to create patch resource path",
", appbase=" + _appbase + ", tvers=" + _targetVersion + "pfile", pfile, "appbase", _appbase, "tvers", _targetVersion, "error", e);
", error=" + e + "].");
return null; return null;
} }
} }
@@ -336,9 +335,8 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), _javaLocation); URL remote = new URL(createVAppBase(_targetVersion), _javaLocation);
return new Resource(vmfile, remote, getLocalPath(vmfile), true); return new Resource(vmfile, remote, getLocalPath(vmfile), true);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to create VM resource [vmfile=" + vmfile + ", appbase=" + _appbase + log.warning("Failed to create VM resource", "vmfile", vmfile, "appbase", _appbase,
", tvers=" + _targetVersion + ", javaloc=" + _javaLocation + "tvers", _targetVersion, "javaloc", _javaLocation, "error", e);
", error=" + e + "].");
return null; return null;
} }
} }
@@ -354,9 +352,8 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), file); URL remote = new URL(createVAppBase(_targetVersion), file);
return new Resource(file, remote, getLocalPath(file), false); return new Resource(file, remote, getLocalPath(file), false);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to create full resource path [file=" + file + log.warning("Failed to create full resource path",
", appbase=" + _appbase + ", tvers=" + _targetVersion + "file", file, "appbase", _appbase, "tvers", _targetVersion, "error", e);
", error=" + e + "].");
return null; return null;
} }
} }
@@ -372,11 +369,9 @@ public class Application
try { try {
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix; String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
String ga = getGATrackingCode(); String ga = getGATrackingCode();
return _trackingURL == null ? return _trackingURL == null ? null : new URL(_trackingURL + event + suffix + ga);
null : new URL(_trackingURL + event + suffix + ga);
} catch (MalformedURLException mue) { } catch (MalformedURLException mue) {
log.warning("Invalid tracking URL [path=" + _trackingURL + ", event=" + event + log.warning("Invalid tracking URL", "path", _trackingURL, "event", event, "error", mue);
", error=" + mue + "].");
return null; return null;
} }
} }
@@ -681,8 +676,8 @@ public class Application
if (!m.matches()) { if (!m.matches()) {
// if we can't parse the java version we're in weird land and should probably just try // if we can't parse the java version we're in weird land and should probably just try
// our luck with what we've got rather than try to download a new jvm // our luck with what we've got rather than try to download a new jvm
log.warning("Unable to parse VM version, hoping for the best [version=" + verstr + log.warning("Unable to parse VM version, hoping for the best",
", needed=" + _javaVersion + "]."); "version", verstr, "needed", _javaVersion);
return true; return true;
} }
@@ -1069,12 +1064,12 @@ public class Application
rsrc.markAsValid(); rsrc.markAsValid();
continue; continue;
} }
log.info("Failure unpacking resource [rsrc=" + rsrc + "]."); log.info("Failure unpacking resource", "rsrc", rsrc);
} }
} catch (Exception e) { } catch (Exception e) {
log.info("Failure validating resource [rsrc=" + rsrc + ", error=" + e + "]. " + log.info("Failure validating resource. Requesting redownload...",
"Requesting redownload..."); "rsrc", rsrc, "error", e);
} finally { } finally {
mpobs.progress(100); mpobs.progress(100);
@@ -1133,13 +1128,13 @@ public class Application
try { try {
_lockChannel = new RandomAccessFile(getLocalPath("gettingdown.lock"), "rw").getChannel(); _lockChannel = new RandomAccessFile(getLocalPath("gettingdown.lock"), "rw").getChannel();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
log.warning("Unable to create lock file [message=" + e.getMessage() + "]", e); log.warning("Unable to create lock file", "message", e.getMessage(), e);
return false; return false;
} }
try { try {
_lock = _lockChannel.tryLock(); _lock = _lockChannel.tryLock();
} catch (IOException e) { } catch (IOException e) {
log.warning("Unable to create lock [message=" + e.getMessage() + "]", e); log.warning("Unable to create lock", "message", e.getMessage(), e);
return false; return false;
} catch (OverlappingFileLockException e) { } catch (OverlappingFileLockException e) {
log.warning("The lock is held elsewhere in this JVM", e); log.warning("The lock is held elsewhere in this JVM", e);
@@ -1159,12 +1154,12 @@ public class Application
try { try {
_lock.release(); _lock.release();
} catch (IOException e) { } catch (IOException e) {
log.warning("Unable to release lock [message=" + e.getMessage() + "]", e); log.warning("Unable to release lock", "message", e.getMessage(), e);
} }
try { try {
_lockChannel.close(); _lockChannel.close();
} catch (IOException e) { } catch (IOException e) {
log.warning("Unable to close lock channel [message=" + e.getMessage() + "]", e); log.warning("Unable to close lock channel", "message", e.getMessage(), e);
} }
_lockChannel = null; _lockChannel = null;
_lock = null; _lock = null;
@@ -1200,7 +1195,7 @@ public class Application
if (validateSignature) { if (validateSignature) {
if (_signers == null) { if (_signers == null) {
log.info("No signers, not verifying file [path=" + path + "]."); log.info("No signers, not verifying file", "path", path);
} else { } else {
File signatureFile = downloadFile(path + SIGNATURE_SUFFIX); File signatureFile = downloadFile(path + SIGNATURE_SUFFIX);
@@ -1232,10 +1227,10 @@ public class Application
} }
if (!sig.verify(Base64.decodeBase64(signature))) { if (!sig.verify(Base64.decodeBase64(signature))) {
log.info("Signature does not match [cert=" + cert.getPublicKey() + "]"); log.info("Signature does not match", "cert", cert.getPublicKey());
continue; continue;
} else { } else {
log.info("Signature matches [cert=" + cert.getPublicKey() + "]"); log.info("Signature matches", "cert", cert.getPublicKey());
validated++; validated++;
} }
@@ -1280,8 +1275,8 @@ public class Application
try { try {
targetURL = getRemoteURL(path); targetURL = getRemoteURL(path);
} catch (Exception e) { } catch (Exception e) {
log.warning("Requested to download invalid control file [appbase=" + _vappbase + log.warning("Requested to download invalid control file",
", path=" + path + ", error=" + e + "]."); "appbase", _vappbase, "path", path, "error", e);
throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e); throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e);
} }
@@ -1355,7 +1350,7 @@ public class Application
} }
/** Used to parse color specifications from the config file. */ /** Used to parse color specifications from the config file. */
protected Color parseColor (HashMap<String,Object> cdata, String name, Color def) protected Color parseColor (HashMap<String, Object> cdata, String name, Color def)
{ {
return parseColor(cdata, name, def, true); return parseColor(cdata, name, def, true);
} }
@@ -1391,7 +1386,7 @@ public class Application
} }
/** Parses a list of strings from the config file. */ /** Parses a list of strings from the config file. */
protected String[] parseList (HashMap<String,Object> cdata, String name) protected String[] parseList (HashMap<String, Object> cdata, String name)
{ {
String value = (String)cdata.get(name); String value = (String)cdata.get(name);
return (value == null) ? new String[0] : StringUtil.parseStringArray(value); return (value == null) ? new String[0] : StringUtil.parseStringArray(value);
@@ -46,8 +46,8 @@ import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log; import static com.threerings.getdown.Log.log;
/** /**
* Manages the <code>digest.txt</code> file and the computing and * Manages the <code>digest.txt</code> file and the computing and processing of MD5 digests for an
* processing of MD5 digests for an application. * application.
*/ */
public class Digest public class Digest
{ {
@@ -55,8 +55,8 @@ public class Digest
public static final String DIGEST_FILE = "digest.txt"; public static final String DIGEST_FILE = "digest.txt";
/** /**
* Creates a digest instance which will parse and validate the * Creates a digest instance which will parse and validate the <code>digest.txt</code> in the
* <code>digest.txt</code> in the supplied application directory. * supplied application directory.
*/ */
public Digest (File appdir) public Digest (File appdir)
throws IOException throws IOException
@@ -78,8 +78,7 @@ public class Digest
byte[] contents = data.toString().getBytes("UTF-8"); byte[] contents = data.toString().getBytes("UTF-8");
String md5 = StringUtil.hexlate(md.digest(contents)); String md5 = StringUtil.hexlate(md.digest(contents));
if (!md5.equals(_metaDigest)) { if (!md5.equals(_metaDigest)) {
String err = MessageUtil.tcompose( String err = MessageUtil.tcompose("m.invalid_digest_file", _metaDigest, md5);
"m.invalid_digest_file", _metaDigest, md5);
throw new IOException(err); throw new IOException(err);
} }
} }
@@ -93,13 +92,11 @@ public class Digest
} }
/** /**
* Computes the MD5 hash of the specified resource and compares it * Computes the MD5 hash of the specified resource and compares it with the value parsed from
* with the value parsed from the digest file. Logs a message if the * the digest file. Logs a message if the resource fails validation.
* resource fails validation.
* *
* @return true if the resource is valid, false if it failed the * @return true if the resource is valid, false if it failed the digest check or if an I/O
* digest check or if an I/O error was encountered during the * error was encountered during the validation process.
* validation process.
*/ */
public boolean validateResource (Resource resource, ProgressObserver obs) public boolean validateResource (Resource resource, ProgressObserver obs)
{ {
@@ -109,18 +106,16 @@ public class Digest
if (cmd5.equals(emd5)) { if (cmd5.equals(emd5)) {
return true; return true;
} }
log.info("Resource failed digest check [rsrc=" + resource + log.info("Resource failed digest check",
", computed=" + cmd5 + ", expected=" + emd5 + "]."); "rsrc", resource, "computed", cmd5, "expected", emd5);
} catch (Throwable t) { } catch (Throwable t) {
log.info("Resource failed digest check [rsrc=" + resource + log.info("Resource failed digest check", "rsrc", resource, "error", t);
", error=" + t + "].");
} }
return false; return false;
} }
/** /**
* Creates a digest file at the specified location using the supplied * Creates a digest file at the specified location using the supplied list of resources.
* list of resources.
*/ */
public static void createDigest (List<Resource> resources, File output) public static void createDigest (List<Resource> resources, File output)
throws IOException throws IOException
@@ -146,15 +141,13 @@ public class Digest
// finally compute and append the digest for the file contents // finally compute and append the digest for the file contents
md.reset(); md.reset();
byte[] contents = data.toString().getBytes("UTF-8"); byte[] contents = data.toString().getBytes("UTF-8");
pout.println(DIGEST_FILE + " = " + pout.println(DIGEST_FILE + " = " + StringUtil.hexlate(md.digest(contents)));
StringUtil.hexlate(md.digest(contents)));
pout.close(); pout.close();
} }
/** /**
* Obtains an appropriate message digest instance for use by the * Obtains an appropriate message digest instance for use by the Getdown system.
* Getdown system.
*/ */
public static MessageDigest getMessageDigest () public static MessageDigest getMessageDigest ()
{ {
@@ -201,7 +201,7 @@ public abstract class Getdown extends Thread
*/ */
public void configureProxy (String host, String port) public void configureProxy (String host, String port)
{ {
log.info("User configured proxy [host=" + host + ", port=" + port + "]."); log.info("User configured proxy", "host", host, "port", port);
// if we're provided with valid values, create a proxy.txt file // if we're provided with valid values, create a proxy.txt file
if (!StringUtil.isBlank(host)) { if (!StringUtil.isBlank(host)) {
@@ -273,7 +273,7 @@ public abstract class Getdown extends Thread
} }
} catch (Throwable t) { } catch (Throwable t) {
log.info("Failed to find proxy settings in Windows registry [error=" + t + "]."); log.info("Failed to find proxy settings in Windows registry", "error", t);
} }
} }
@@ -347,7 +347,7 @@ public abstract class Getdown extends Thread
if (!StringUtil.isBlank(port)) { if (!StringUtil.isBlank(port)) {
System.setProperty("http.proxyPort", port); System.setProperty("http.proxyPort", port);
} }
log.info("Using proxy [host=" + host + ", port=" + port + "]."); log.info("Using proxy", "host", host, "port", port);
} }
} }
@@ -525,7 +525,7 @@ public abstract class Getdown extends Thread
imgpath = _app.getLocalPath(path); imgpath = _app.getLocalPath(path);
return ImageIO.read(imgpath); return ImageIO.read(imgpath);
} catch (IOException ioe2) { } catch (IOException ioe2) {
log.warning("Failed to load image [path=" + imgpath + ", error=" + ioe2 + "]."); log.warning("Failed to load image", "path", imgpath, "error", ioe2);
return null; return null;
} }
} }
@@ -568,8 +568,7 @@ public abstract class Getdown extends Thread
log.info("Please smack a Java engineer. Running: " + cmd); log.info("Please smack a Java engineer. Running: " + cmd);
Runtime.getRuntime().exec(cmd); Runtime.getRuntime().exec(cmd);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to mark VM binary as executable [cmd=" + cmd + log.warning("Failed to mark VM binary as executable", "cmd", cmd, "error", e);
", error=" + e + "].");
// we should do something like tell the user or something but fucking fuck // we should do something like tell the user or something but fucking fuck
} }
} }
@@ -580,7 +579,7 @@ public abstract class Getdown extends Thread
log.info("Regenerating classes.jsa for " + vmpath + "..."); log.info("Regenerating classes.jsa for " + vmpath + "...");
Runtime.getRuntime().exec(vmpath + " -Xshare:dump"); Runtime.getRuntime().exec(vmpath + " -Xshare:dump");
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to regenerate .jsa dum file [error=" + e + "]."); log.warning("Failed to regenerate .jsa dum file", "error", e);
} }
reportTrackingEvent("jvm_complete", -1); reportTrackingEvent("jvm_complete", -1);
@@ -621,7 +620,7 @@ public abstract class Getdown extends Thread
Patcher patcher = new Patcher(); Patcher patcher = new Patcher();
patcher.patch(prsrc.getLocal().getParentFile(), prsrc.getLocal(), _progobs); patcher.patch(prsrc.getLocal().getParentFile(), prsrc.getLocal(), _progobs);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to apply patch [prsrc=" + prsrc + "].", e); log.warning("Failed to apply patch", "prsrc", prsrc, e);
} }
// clean up the patch file // clean up the patch file
@@ -683,7 +682,7 @@ public abstract class Getdown extends Thread
public void downloadFailed (Resource rsrc, Exception e) { public void downloadFailed (Resource rsrc, Exception e) {
updateStatus(MessageUtil.tcompose("m.failure", e.getMessage())); updateStatus(MessageUtil.tcompose("m.failure", e.getMessage()));
log.warning("Download failed [rsrc=" + rsrc + "].", e); log.warning("Download failed", "rsrc", rsrc, e);
} }
/** The last percentage at which we checked for another getdown running, or -1 for not /** The last percentage at which we checked for another getdown running, or -1 for not
@@ -950,7 +949,7 @@ public abstract class Getdown extends Thread
out.flush(); out.flush();
} }
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failure copying [in=" + in + ", out=" + out + ", error=" + ioe + "]."); log.warning("Failure copying", "in", in, "out", out, "error", ioe);
} }
} }
@@ -980,16 +979,15 @@ public abstract class Getdown extends Thread
ucon.connect(); ucon.connect();
try { try {
if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) {
log.warning("Failed to report tracking event [url=" + _url + log.warning("Failed to report tracking event",
", rcode=" + ucon.getResponseCode() + "]."); "url", _url, "rcode", ucon.getResponseCode());
} }
} finally { } finally {
ucon.disconnect(); ucon.disconnect();
} }
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failed to report tracking event [url=" + _url + log.warning("Failed to report tracking event", "url", _url, "error", ioe);
", error=" + ioe + "].");
} }
} }