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