diff options
author | Keith Packard <keithp@keithp.com> | 2013-12-18 01:14:11 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-12-18 01:14:11 -0800 |
commit | e26306c9350ef1d107d4257ef1c09d15165c9154 (patch) | |
tree | d7983c6a04c54b3307d6fc2699dad4fa21d8bde0 /altoslib/AltosTelemetryReader.java | |
parent | 18852efa108ba6e6e69dfd5076d4f4c01f62b4ef (diff) |
altoslib: Pass InterruptedException up the stack instead of hiding it
When interrupting a thread that is talking to a serial device, it's
important not to have that thread discard the InterruptedException so
that it will actually terminate. This patch removes a bunch of places
that were discarding InterruptedExceptions and lets higher level code
see them so that they can exit cleanly.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosTelemetryReader.java')
-rw-r--r-- | altoslib/AltosTelemetryReader.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index aea97844..405c555b 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -54,7 +54,10 @@ public class AltosTelemetryReader extends AltosFlightReader { public void close(boolean interrupted) { link.remove_monitor(telem); log.close(); - link.close(); + try { + link.close(); + } catch (InterruptedException ie) { + } } public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException { @@ -83,7 +86,7 @@ public class AltosTelemetryReader extends AltosFlightReader { else return false; } catch (InterruptedException ie) { - return true; + return false; } catch (TimeoutException te) { return true; } @@ -114,7 +117,7 @@ public class AltosTelemetryReader extends AltosFlightReader { return link.has_monitor_battery(); } - public double monitor_battery() { + public double monitor_battery() throws InterruptedException { return link.monitor_battery(); } @@ -130,12 +133,8 @@ public class AltosTelemetryReader extends AltosFlightReader { telemetry = AltosPreferences.telemetry(link.serial); set_telemetry(telemetry); link.add_monitor(telem); - } catch (TimeoutException e) { - close(true); - throw(e); - } catch (InterruptedException e) { + } finally { close(true); - throw(e); } } } |