mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Don't swallow interrupts.
This commit is contained in:
@@ -37,8 +37,7 @@ class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
|
||||
try {
|
||||
wait(msBetweenSweeps);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} catch(DbException e) {
|
||||
|
||||
@@ -393,8 +393,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
try {
|
||||
connections.wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
txn = connections.poll();
|
||||
@@ -462,8 +461,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
try {
|
||||
connections.wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
for(Connection c : connections) c.close();
|
||||
openConnections -= connections.size();
|
||||
|
||||
@@ -77,7 +77,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
try {
|
||||
hook.join();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ class PollerImpl implements Poller, Runnable {
|
||||
try {
|
||||
wait(p.time - now);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamPlugin {
|
||||
Thread.sleep(c.getTimeout());
|
||||
scn.close();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ConnectionCallback {
|
||||
try {
|
||||
wait(end - now);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
now = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class ContactListener extends AbstractListener {
|
||||
try {
|
||||
finished.await();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class InvitationListener extends AbstractListener {
|
||||
try {
|
||||
finished.await();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,9 @@ package net.sf.briar.plugins.file;
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
class FileListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(FileListener.class.getName());
|
||||
|
||||
private final String filename;
|
||||
private final long end;
|
||||
private final CountDownLatch finished = new CountDownLatch(1);
|
||||
@@ -27,7 +22,7 @@ class FileListener {
|
||||
try {
|
||||
finished.await(end - now, TimeUnit.MILLISECONDS);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,9 @@ package net.sf.briar.plugins.file;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(PollingRemovableDriveMonitor.class.getName());
|
||||
|
||||
private final RemovableDriveFinder finder;
|
||||
private final long pollingInterval;
|
||||
private final Object pollingLock = new Object();
|
||||
@@ -53,8 +48,7 @@ class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
|
||||
try {
|
||||
pollingLock.wait(pollingInterval);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if(!running) return;
|
||||
|
||||
@@ -2,9 +2,6 @@ package net.sf.briar.transport;
|
||||
|
||||
import static net.sf.briar.api.transport.TransportConstants.MAX_FRAME_LENGTH;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A thread that calls the writeFullFrame() method of a PaddedConnectionWriter
|
||||
* at regular intervals. The interval between calls is determined by a target
|
||||
@@ -13,9 +10,6 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
class FrameScheduler extends Thread {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(FrameScheduler.class.getName());
|
||||
|
||||
private final PaddedConnectionWriter writer;
|
||||
private final int millisPerFrame;
|
||||
|
||||
@@ -34,8 +28,7 @@ class FrameScheduler extends Thread {
|
||||
try {
|
||||
Thread.sleep(nextCall - now);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
lastCall = System.currentTimeMillis();
|
||||
|
||||
@@ -108,7 +108,7 @@ class PaddedConnectionWriter extends ConnectionWriterImpl {
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if(exception != null) throw exception;
|
||||
}
|
||||
|
||||
@@ -218,8 +218,7 @@ abstract class StreamConnection implements DatabaseListener {
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
flags = writerFlags;
|
||||
@@ -258,8 +257,7 @@ abstract class StreamConnection implements DatabaseListener {
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
flags = writerFlags;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class LockFairnessTest extends TestCase {
|
||||
Thread.sleep(sleepTime);
|
||||
finished.add(this);
|
||||
} catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class LockFairnessTest extends TestCase {
|
||||
Thread.sleep(sleepTime);
|
||||
finished.add(this);
|
||||
} catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class WindowsShutdownManagerImplTest extends ShutdownManagerImplTest {
|
||||
Thread.sleep(100);
|
||||
finished = true;
|
||||
} catch(InterruptedException e) {
|
||||
// Don't finish
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user