BOB findbugs

This commit is contained in:
str4d
2013-11-20 09:56:57 +00:00
parent a7a7e96188
commit 413ad6b0e6
6 changed files with 20 additions and 19 deletions

View File

@ -308,7 +308,7 @@ public class BOB {
database.releaseReadLock();
database.getWriteLock();
nickinfo.getWriteLock();
nickinfo.add(P_STOPPING, new Boolean(true));
nickinfo.add(P_STOPPING, Boolean.valueOf(true));
nickinfo.releaseWriteLock();
database.releaseWriteLock();
} else {

View File

@ -665,7 +665,7 @@ public class DoCMDS implements Runnable {
break die;
}
try {
nickinfo.add(P_QUIET, new Boolean(Boolean.parseBoolean(Arg) == true));
nickinfo.add(P_QUIET, Boolean.valueOf(Arg));
} catch (Exception ex) {
try {
wunlock();
@ -989,7 +989,7 @@ public class DoCMDS implements Runnable {
prt = Integer.parseInt(Arg);
if (prt > 1 && prt < 65536) {
try {
nickinfo.add(P_INPORT, new Integer(prt));
nickinfo.add(P_INPORT, Integer.valueOf(prt));
} catch (Exception ex) {
try {
wunlock();

View File

@ -70,7 +70,7 @@ public class MUXlisten implements Runnable {
this.database.getWriteLock();
this.info.getWriteLock();
this.info.add("STARTING", new Boolean(true));
this.info.add("STARTING", Boolean.valueOf(true));
this.info.releaseWriteLock();
this.database.releaseWriteLock();
this.database.getReadLock();
@ -160,7 +160,7 @@ public class MUXlisten implements Runnable {
try {
wlock();
try {
info.add("RUNNING", new Boolean(true));
info.add("RUNNING", Boolean.valueOf(true));
} catch (Exception e) {
lock.set(false);
wunlock();

View File

@ -15,6 +15,8 @@
*/
package net.i2p.BOB;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Internal database to relate nicknames to options to values
*
@ -23,7 +25,9 @@ package net.i2p.BOB;
public class NamedDB {
private volatile Object[][] data;
private volatile int index, writersWaiting, readers;
private volatile int index;
private final AtomicInteger writersWaiting = new AtomicInteger();
private final AtomicInteger readers = new AtomicInteger();
/**
* make initial NULL object
@ -31,27 +35,27 @@ public class NamedDB {
*/
public NamedDB() {
this.data = new Object[1][2];
this.index = this.writersWaiting = this.readers = 0;
this.index = 0;
}
synchronized public void getReadLock() {
while ((writersWaiting != 0)) {
while ((writersWaiting.get() != 0)) {
try {
wait();
} catch (InterruptedException ie) {
}
}
readers++;
readers.incrementAndGet();
}
synchronized public void releaseReadLock() {
readers--;
readers.decrementAndGet();
notifyAll();
}
synchronized public void getWriteLock() {
writersWaiting++;
while (readers != 0 && writersWaiting != 1) {
writersWaiting.incrementAndGet();
while (readers.get() != 0 && writersWaiting.get() != 1) {
try {
wait();
} catch (InterruptedException ie) {
@ -60,7 +64,7 @@ public class NamedDB {
}
synchronized public void releaseWriteLock() {
writersWaiting--;
writersWaiting.decrementAndGet();
notifyAll();
}

View File

@ -116,7 +116,6 @@ public class TCPio implements Runnable {
Aout.close();
} catch (IOException ex) {
}
return;
}
}
}

View File

@ -70,12 +70,10 @@ public class TCPtoI2P implements Runnable {
* @throws IOException
*/
private static String lnRead(InputStream in) throws IOException {
String S;
String S = "";
int b;
char c;
S = new String();
while (true) {
b = in.read();
if (b == 13) {
@ -87,7 +85,7 @@ public class TCPtoI2P implements Runnable {
break;
}
c = (char) (b & 0x7f); // We only care about ASCII
S = new String(S + c);
S = S + c;
}
return S;
}
@ -101,7 +99,7 @@ public class TCPtoI2P implements Runnable {
*/
private void Emsg(String e, OutputStream out) throws IOException {
// Debugging System.out.println("ERROR TCPtoI2P: " + e);
out.write("ERROR ".concat(e).getBytes());
out.write("ERROR ".concat(e).getBytes("UTF-8"));
out.write(13);
out.write(10);
out.flush();