mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Call Thread.currentThread().interrupt() when handling interruption.
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ class AndroidExecutorImpl implements AndroidExecutor {
|
|||||||
|
|
||||||
private static final int SHUTDOWN = 0, RUN = 1;
|
private static final int SHUTDOWN = 0, RUN = 1;
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
Logger.getLogger(AndroidExecutorImpl.class.getName());
|
||||||
|
|
||||||
private final Runnable loop;
|
private final Runnable loop;
|
||||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
private final CountDownLatch startLatch = new CountDownLatch(1);
|
private final CountDownLatch startLatch = new CountDownLatch(1);
|
||||||
@@ -43,6 +47,7 @@ class AndroidExecutorImpl implements AndroidExecutor {
|
|||||||
try {
|
try {
|
||||||
startLatch.await();
|
startLatch.await();
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
|
LOG.warning("Interrupted while starting executor thread");
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class BriarActivity extends RoboFragmentActivity {
|
|||||||
service.waitForShutdown();
|
service.waitForShutdown();
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
LOG.warning("Interrupted while waiting for service");
|
LOG.warning("Interrupted while waiting for service");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
finishAndExit();
|
finishAndExit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
LOG.warning("Interrupted while getting BluetoothAdapter");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
throw new IOException(e.toString());
|
Thread.currentThread().interrupt();
|
||||||
|
throw new IOException("Interrupted while getting BluetoothAdapter");
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
throw new IOException(e.toString());
|
throw new IOException(e.toString());
|
||||||
}
|
}
|
||||||
@@ -427,6 +428,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
addresses = discoverDevices(end - now);
|
addresses = discoverDevices(end - now);
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
LOG.warning("Interrupted while discovering devices");
|
LOG.warning("Interrupted while discovering devices");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Connect to any device with the right UUID
|
// Connect to any device with the right UUID
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
|
|||||||
}
|
}
|
||||||
} catch(InterruptedException e1) {
|
} catch(InterruptedException e1) {
|
||||||
LOG.warning("Interrupted while starting Tor");
|
LOG.warning("Interrupted while starting Tor");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Now we should be able to connect to the new process
|
// Now we should be able to connect to the new process
|
||||||
@@ -471,6 +472,8 @@ class TorPlugin implements DuplexPlugin, EventHandler {
|
|||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
LOG.warning("Interrupted while creating hidden service");
|
LOG.warning("Interrupted while creating hidden service");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Publish the hidden service's onion hostname in transport properties
|
// Publish the hidden service's onion hostname in transport properties
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
|
|||||||
for(Connector c : connectors) c.join();
|
for(Connector c : connectors) c.join();
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
LOG.warning("Interrupted while waiting for connectors");
|
LOG.warning("Interrupted while waiting for connectors");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
// If none of the threads connected, inform the listeners
|
// If none of the threads connected, inform the listeners
|
||||||
if(!connected.get()) {
|
if(!connected.get()) {
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ abstract class DuplexConnection implements EventListener {
|
|||||||
}
|
}
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
LOG.warning("Interrupted while waiting for task");
|
LOG.warning("Interrupted while waiting for task");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
dispose(true, true);
|
dispose(true, true);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
|
|||||||
Reference in New Issue
Block a user