From 2981de4b0cbf75429465313b061a98ab9ef98506 Mon Sep 17 00:00:00 2001 From: Rogier Slag Date: Thu, 29 Oct 2015 12:13:40 +0100 Subject: [PATCH] Add more logging to check for synchronized blocks --- .../nl/inventid/rfidReader2keyboard/Read.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/nl/inventid/rfidReader2keyboard/Read.java b/src/main/java/nl/inventid/rfidReader2keyboard/Read.java index 3e3ae4a..0b5a86b 100644 --- a/src/main/java/nl/inventid/rfidReader2keyboard/Read.java +++ b/src/main/java/nl/inventid/rfidReader2keyboard/Read.java @@ -122,7 +122,9 @@ public Read(ScheduledThreadPoolExecutor executorService) { */ private void determineCardTerminalToUse() { try { + System.out.println("Will enter sychronizer block [determineCardTerminalToUse]"); synchronized (synchronizer) { + System.out.println("Inside sychronizer block [determineCardTerminalToUse]"); // show the list of available terminals TerminalFactory factory = TerminalFactory.getDefault(); List terminals = factory.terminals().list(); @@ -141,6 +143,7 @@ private void determineCardTerminalToUse() { } } } + System.out.println("Exited sychronizer block [determineCardTerminalToUse]"); } catch (Throwable e) { // Probably no reader found... @@ -157,7 +160,9 @@ private void determineCardTerminalToUse() { */ public void findAndConnectToTerminal() { try { + System.out.println("Will enter sychronizer block [findAndConnectToTerminal]"); synchronized (synchronizer) { + System.out.println("Inside sychronizer block [findAndConnectToTerminal]"); // show the list of available terminals TerminalFactory factory = TerminalFactory.getDefault(); List terminals = factory.terminals().list(); @@ -170,6 +175,7 @@ public void findAndConnectToTerminal() { } } } + System.out.println("Exited sychronizer block [findAndConnectToTerminal]"); } catch (Throwable e) { // Probably no reader found... @@ -200,7 +206,9 @@ public void run() { return; } try { + System.out.println("Will enter sychronizer block [run]"); synchronized (synchronizer) { + System.out.println("Inside sychronizer block [run]"); // Connect to card and read Card card = terminal.connect("T=1"); @@ -224,6 +232,7 @@ public void run() { System.out.println("ready for next card"); System.out.println("Card scan run: " + i); } + System.out.println("Exited sychronizer block [run]"); } catch (CardException e) { // Something went wrong when scanning the card @@ -271,17 +280,21 @@ public void run() { * @throws CardException in case of an error */ private String getCardUid(CardChannel channel) throws CardException { + System.out.println("Will enter sychronizer block [getCardUid]"); + String uid; synchronized (synchronizer) { + System.out.println("Inside sychronizer block [getCardUid]"); ResponseAPDU response = channel.transmit(READ_COMMAND); - String uid = new String(Hex.encodeHex(response.getData())).toUpperCase(); + uid = new String(Hex.encodeHex(response.getData())).toUpperCase(); if (!new String(Hex.encodeHex(response.getBytes())).endsWith("9000")) { throw new CardException(CARD_READ_FAILURE); } if (uid.isEmpty()) { throw new CardException(EMPTY_CODE); } - return uid; } + System.out.println("Exited sychronizer block [getCardUid]"); + return uid; } /**