[or-cvs] r15871: updated changelog, removed some unnecessary casts (in torctl/trunk: . java/net/freehaven/tor/control)
sebastian at seul.org
sebastian at seul.org
Sun Jul 13 08:49:46 UTC 2008
Author: sebastian
Date: 2008-07-13 04:49:46 -0400 (Sun, 13 Jul 2008)
New Revision: 15871
Modified:
torctl/trunk/ChangeLog
torctl/trunk/java/net/freehaven/tor/control/Bytes.java
torctl/trunk/java/net/freehaven/tor/control/PasswordDigest.java
torctl/trunk/java/net/freehaven/tor/control/TorControlConnection.java
Log:
updated changelog, removed some unnecessary casts
Modified: torctl/trunk/ChangeLog
===================================================================
--- torctl/trunk/ChangeLog 2008-07-13 08:10:14 UTC (rev 15870)
+++ torctl/trunk/ChangeLog 2008-07-13 08:49:46 UTC (rev 15871)
@@ -11,5 +11,6 @@
- Remove all v0 support; merge TorControlConnection1 into
TorControlConnection. (Java; from Karsten)
- (Java): Add generics support where applicable. (Sebastian)
- - (Java): Waiter.response is no longer an object. (Sebastian)
+ - (Java): Waiter.response is no longer of type Object. (Sebastian)
+ - (Java): removed some unnecessary casts. (Sebastian)
Modified: torctl/trunk/java/net/freehaven/tor/control/Bytes.java
===================================================================
--- torctl/trunk/java/net/freehaven/tor/control/Bytes.java 2008-07-13 08:10:14 UTC (rev 15870)
+++ torctl/trunk/java/net/freehaven/tor/control/Bytes.java 2008-07-13 08:49:46 UTC (rev 15871)
@@ -40,7 +40,7 @@
}
public static String getU32S(byte[] ba, int pos) {
- return String.valueOf( ((long)getU32(ba,pos))&0xffffffffL );
+ return String.valueOf( (getU32(ba,pos))&0xffffffffL );
}
/** Return the two-byte value starting at index 'pos' within 'ba' */
@@ -103,7 +103,7 @@
public static final String hex(byte[] ba) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < ba.length; ++i) {
- int b = ((int)ba[i]) & 0xff;
+ int b = (ba[i]) & 0xff;
buf.append(NYBBLES[b >> 4]);
buf.append(NYBBLES[b&0x0f]);
}
Modified: torctl/trunk/java/net/freehaven/tor/control/PasswordDigest.java
===================================================================
--- torctl/trunk/java/net/freehaven/tor/control/PasswordDigest.java 2008-07-13 08:10:14 UTC (rev 15870)
+++ torctl/trunk/java/net/freehaven/tor/control/PasswordDigest.java 2008-07-13 08:49:46 UTC (rev 15871)
@@ -67,7 +67,7 @@
} catch (java.security.NoSuchAlgorithmException ex) {
throw new RuntimeException("Can't run without sha-1.");
}
- int c = ((int)specifier[8])&0xff;
+ int c = (specifier[8])&0xff;
int count = (16 + (c&15)) << ((c>>4) + EXPBIAS);
byte[] tmp = new byte[8+secret.length];
Modified: torctl/trunk/java/net/freehaven/tor/control/TorControlConnection.java
===================================================================
--- torctl/trunk/java/net/freehaven/tor/control/TorControlConnection.java 2008-07-13 08:10:14 UTC (rev 15870)
+++ torctl/trunk/java/net/freehaven/tor/control/TorControlConnection.java 2008-07-13 08:49:46 UTC (rev 15871)
@@ -75,14 +75,12 @@
/** Create a new TorControlConnection to communicate with Tor over
* an arbitrary pair of data streams.
*/
- public TorControlConnection(java.io.InputStream i, java.io.OutputStream o)
- throws IOException {
+ public TorControlConnection(java.io.InputStream i, java.io.OutputStream o) {
this(new java.io.InputStreamReader(i),
new java.io.OutputStreamWriter(o));
}
- public TorControlConnection(java.io.Reader i, java.io.Writer o)
- throws IOException {
+ public TorControlConnection(java.io.Reader i, java.io.Writer o) {
this.output = o;
if (i instanceof java.io.BufferedReader)
this.input = (java.io.BufferedReader) i;
@@ -140,11 +138,10 @@
if (reply.isEmpty()) {
// nothing received so far, can exit cleanly
return reply;
- } else {
- // received half of a reply before the connection broke down
- throw new TorControlSyntaxError("Connection to Tor " +
- " broke down while receiving reply!");
- }
+ }
+ // received half of a reply before the connection broke down
+ throw new TorControlSyntaxError("Connection to Tor " +
+ " broke down while receiving reply!");
}
if (debugOutput != null)
debugOutput.println("<< "+line);
@@ -209,22 +206,22 @@
String rest = line.msg.substring(idx+1);
if (tp.equals("CIRC")) {
List<String> lst = Bytes.splitStr(null, rest);
- handler.circuitStatus((String)lst.get(1),
- (String)lst.get(0),
- (String)lst.get(2));
+ handler.circuitStatus(lst.get(1),
+ lst.get(0),
+ lst.get(2));
} else if (tp.equals("STREAM")) {
List<String> lst = Bytes.splitStr(null, rest);
- handler.streamStatus((String)lst.get(1),
- (String)lst.get(0),
- (String)lst.get(3));
+ handler.streamStatus(lst.get(1),
+ lst.get(0),
+ lst.get(3));
// XXXX circID.
} else if (tp.equals("ORCONN")) {
List<String> lst = Bytes.splitStr(null, rest);
- handler.orConnStatus((String)lst.get(1), (String)lst.get(0));
+ handler.orConnStatus(lst.get(1), lst.get(0));
} else if (tp.equals("BW")) {
List<String> lst = Bytes.splitStr(null, rest);
- handler.bandwidthUsed(Integer.parseInt((String)lst.get(0)),
- Integer.parseInt((String)lst.get(1)));
+ handler.bandwidthUsed(Integer.parseInt(lst.get(0)),
+ Integer.parseInt(lst.get(1)));
} else if (tp.equals("NEWDESC")) {
List<String> lst = Bytes.splitStr(null, rest);
handler.newDescriptors(lst);
@@ -282,14 +279,14 @@
protected class ControlParseThread extends Thread {
boolean stopped = false;
- public void run() {
+ @Override
+ public void run() {
try {
react();
} catch (SocketException ex) {
if (stopped) // we expected this exception
return;
- else
- throw new RuntimeException(ex);
+ throw new RuntimeException(ex);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
@@ -317,7 +314,7 @@
else {
Waiter w;
synchronized (waiters) {
- w = (Waiter) waiters.removeFirst();
+ w = waiters.removeFirst();
}
w.setResponse(lst);
}
@@ -422,7 +419,7 @@
List<ReplyLine> lst = sendAndWaitForResponse(sb.toString(), null);
List<ConfigEntry> result = new ArrayList<ConfigEntry>();
for (Iterator<ReplyLine> it = lst.iterator(); it.hasNext(); ) {
- String kv = ((ReplyLine) it.next()).msg;
+ String kv = (it.next()).msg;
int idx = kv.indexOf('=');
if (idx >= 0)
result.add(new ConfigEntry(kv.substring(0, idx),
@@ -550,7 +547,7 @@
List<ReplyLine> lst = sendAndWaitForResponse(sb.toString(), null);
Map<String,String> result = new HashMap<String,String>();
for (Iterator<ReplyLine> it = lst.iterator(); it.hasNext(); ) {
- String kv = ((ReplyLine) it.next()).msg;
+ String kv = (it.next()).msg;
int idx = kv.indexOf('=');
result.put(kv.substring(0, idx),
kv.substring(idx+1));
More information about the tor-commits
mailing list