Don't swallow interrupts.

This commit is contained in:
akwizgran
2011-12-01 19:49:22 +00:00
parent 2a38efd13a
commit 28b9e399ae
15 changed files with 18 additions and 42 deletions

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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();
} }
} }
} }

View File

@@ -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());
} }
} }
} }

View File

@@ -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());
} }

View File

@@ -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();
} }

View File

@@ -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;
} }

View File

@@ -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;
} }

View File

@@ -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;
} }

View 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;

View File

@@ -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();

View File

@@ -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;
} }

View File

@@ -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;

View File

@@ -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();
} }

View File

@@ -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();
} }
} }
} }