Drive-by: a bit of modernization & warning cleanup, UTF-8 edition.
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package com.threerings.io;
|
package com.threerings.io;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -374,8 +376,7 @@ public class ObjectInputStream extends DataInputStream
|
|||||||
// read precisely that many into a buffer
|
// read precisely that many into a buffer
|
||||||
byte[] bbuf = new byte[utflen];
|
byte[] bbuf = new byte[utflen];
|
||||||
in.read(bbuf);
|
in.read(bbuf);
|
||||||
return new String(bbuf, "UTF-8");
|
return new String(bbuf, UTF_8);
|
||||||
//return new String(bbuf, Charsets.UTF_8); // TODO Java 6 (Charsets is from guava)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package com.threerings.io;
|
package com.threerings.io;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -288,8 +290,7 @@ public class ObjectOutputStream extends DataOutputStream
|
|||||||
public void writeUnmodifiedUTF (String str)
|
public void writeUnmodifiedUTF (String str)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// byte[] bytes = str.getBytes(Charsets.UTF_8); // TODO Java 6 (Charsets is from guava)
|
byte[] bytes = str.getBytes(UTF_8);
|
||||||
byte[] bytes = str.getBytes("UTF-8");
|
|
||||||
writeShort(bytes.length);
|
writeShort(bytes.length);
|
||||||
write(bytes);
|
write(bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
package com.threerings.nio;
|
package com.threerings.nio;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@@ -78,11 +78,7 @@ public class PolicyServer extends ConnectionManager
|
|||||||
policy.append(" <allow-access-from domain=\"*\" to-ports=\"*\"/>\n");
|
policy.append(" <allow-access-from domain=\"*\" to-ports=\"*\"/>\n");
|
||||||
policy.append("</cross-domain-policy>\n\n");
|
policy.append("</cross-domain-policy>\n\n");
|
||||||
|
|
||||||
try {
|
_policy = policy.toString().getBytes(UTF_8);
|
||||||
_policy = policy.toString().getBytes("UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new IllegalStateException("UTF-8 encoding missing; this vm is broken", e);
|
|
||||||
}
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +112,7 @@ public class PolicyServer extends ConnectionManager
|
|||||||
sendPolicy(this);
|
sendPolicy(this);
|
||||||
return buf.position();
|
return buf.position();
|
||||||
}
|
}
|
||||||
log.warning("Bad policy request", "request", new String(buf.array(), Charsets.UTF_8));
|
log.warning("Bad policy request", "request", new String(buf.array(), UTF_8));
|
||||||
_cmgr.closeConnection(this);
|
_cmgr.closeConnection(this);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -138,7 +134,7 @@ public class PolicyServer extends ConnectionManager
|
|||||||
|
|
||||||
protected byte[] _policy;
|
protected byte[] _policy;
|
||||||
|
|
||||||
protected static final byte[] REQUEST = "<policy-file-request/>\0".getBytes(Charsets.UTF_8);
|
protected static final byte[] REQUEST = "<policy-file-request/>\0".getBytes(UTF_8);
|
||||||
|
|
||||||
protected static final int MASTER_PORT = 843;
|
protected static final int MASTER_PORT = 843;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package com.threerings.presents.client;
|
package com.threerings.presents.client;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
@@ -823,7 +825,7 @@ public class BlockingCommunicator extends Communicator
|
|||||||
shutdown();
|
shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_secret = _client.getCredentials().getDatagramSecret().getBytes("UTF-8");
|
_secret = _client.getCredentials().getDatagramSecret().getBytes(UTF_8);
|
||||||
|
|
||||||
// create our various streams
|
// create our various streams
|
||||||
_bout = new ByteBufferOutputStream();
|
_bout = new ByteBufferOutputStream();
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package com.threerings.presents.server.net;
|
package com.threerings.presents.server.net;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -126,11 +128,7 @@ public class PresentsConnection extends Connection
|
|||||||
*/
|
*/
|
||||||
public void setDatagramSecret (String secret)
|
public void setDatagramSecret (String secret)
|
||||||
{
|
{
|
||||||
try {
|
_datagramSecret = secret.getBytes(UTF_8);
|
||||||
_datagramSecret = secret.getBytes("UTF-8");
|
|
||||||
} catch (Exception e) {
|
|
||||||
_datagramSecret = new byte[0]; // shouldn't happen
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public abstract class GenTask extends Task
|
|||||||
}
|
}
|
||||||
log("Writing file " + outputPath, Project.MSG_VERBOSE);
|
log("Writing file " + outputPath, Project.MSG_VERBOSE);
|
||||||
|
|
||||||
new PrintWriter(dest, "UTF-8").append(output).close();
|
new PrintWriter(dest, UTF_8).append(output).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user