From 8c9eae051a9209db71e636694bac55f98405aac4 Mon Sep 17 00:00:00 2001 From: gumartinm Date: Fri, 7 Dec 2012 19:40:20 +0100 Subject: [PATCH] Restore interrupt status before throwing exception Always write the restore interrupt status just after catching th Interrupted exception. In this way you make sure the interrupt status is not lost because something in your code throws an exception before the line where you actually restore the interrupt status. --- .../main/java/de/javapos/example/hardware/KeyBoardDeviceLinux.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JavaPOS/KeyBoardDriver/src/main/java/de/javapos/example/hardware/KeyBoardDeviceLinux.java b/JavaPOS/KeyBoardDriver/src/main/java/de/javapos/example/hardware/KeyBoardDeviceLinux.java index 2c7edd8..2c26547 100644 --- a/JavaPOS/KeyBoardDriver/src/main/java/de/javapos/example/hardware/KeyBoardDeviceLinux.java +++ b/JavaPOS/KeyBoardDriver/src/main/java/de/javapos/example/hardware/KeyBoardDeviceLinux.java @@ -116,9 +116,9 @@ public class KeyBoardDeviceLinux implements BaseKeyBoardDriver { throw new JposException(JposConst.JPOS_E_CLAIMED, "Error while trying to claim device.", e); } catch (InterruptedException e) { - closeFileLock(fileChannelLock); // restore interrupt status. Thread.currentThread().interrupt(); + closeFileLock(fileChannelLock); throw new JposException(JposConst.JPOSERR, "Interrupt exception detected.", e); } @@ -152,9 +152,9 @@ public class KeyBoardDeviceLinux implements BaseKeyBoardDriver { throw new JposException(JposConst.JPOS_E_CLAIMED, "Error while trying to claim device.", e); } catch (InterruptedException e) { - closeFileLock(fileChannelLock); // restore interrupt status. Thread.currentThread().interrupt(); + closeFileLock(fileChannelLock); throw new JposException(JposConst.JPOSERR, "Interrupt exception detected.", e); } @@ -179,7 +179,7 @@ public class KeyBoardDeviceLinux implements BaseKeyBoardDriver { fileChannelLock.close(); } catch (IOException e) { throw new JposException(JposConst.JPOSERR, - "Error while closing the file lock", e); + "Error while closing the lock file", e); } } -- 2.1.4