From 33153babb8f5819fe68a5445ebbf5c4d5ee0867d Mon Sep 17 00:00:00 2001 From: Andrei Cristea Date: Thu, 19 Feb 2026 17:18:06 +0100 Subject: [PATCH] refactor: normalize log and exception messages --- CHANGELOG.md | 8 ++++++-- build.gradle.kts | 10 ++++++---- .../keyple/plugin/stub/StubPoolPluginAdapter.java | 4 ++-- .../keyple/plugin/stub/StubReaderAdapter.java | 15 ++++++++------- .../eclipse/keyple/plugin/stub/StubSmartCard.java | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a4a5d0..b73c842 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed -- Logging improvement. -### Changed +- Normalized logging and error messages using Keyple coding standards. - Migrated the CI pipeline from Jenkins to GitHub Actions. +### Upgraded +- `keyple-common-java-api` from `2.0.1` to `2.0.2` (source code not impacted) +- `keyple-plugin-java-api` from `2.3.1` to `2.3.2` (source code not impacted) +- `keyple-util-java-lib` from `2.4.0` to `2.4.1` (source code not impacted) +- `slf4j-api` from `1.7.32` to `1.7.36` (`compileOnly`) ## [2.2.1] - 2024-04-12 ### Changed diff --git a/build.gradle.kts b/build.gradle.kts index de0f2bc..8fd3048 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,10 +14,12 @@ plugins { /////////////////////////////////////////////////////////////////////////////// dependencies { - implementation("org.eclipse.keyple:keyple-common-java-api:2.0.1") - implementation("org.eclipse.keyple:keyple-plugin-java-api:2.3.1") - implementation("org.eclipse.keyple:keyple-util-java-lib:2.4.0") - implementation("org.slf4j:slf4j-api:1.7.32") + implementation("org.eclipse.keyple:keyple-common-java-api:2.0.2") + implementation("org.eclipse.keyple:keyple-plugin-java-api:2.3.2") + implementation("org.eclipse.keyple:keyple-util-java-lib:2.4.1") + compileOnly("org.slf4j:slf4j-api:1.7.36") + + testImplementation("org.slf4j:slf4j-simple:1.7.36") testImplementation(platform("org.junit:junit-bom:5.10.2")) testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.junit.vintage:junit-vintage-engine") diff --git a/src/main/java/org/eclipse/keyple/plugin/stub/StubPoolPluginAdapter.java b/src/main/java/org/eclipse/keyple/plugin/stub/StubPoolPluginAdapter.java index 8ef818b..bf8fdbf 100644 --- a/src/main/java/org/eclipse/keyple/plugin/stub/StubPoolPluginAdapter.java +++ b/src/main/java/org/eclipse/keyple/plugin/stub/StubPoolPluginAdapter.java @@ -109,7 +109,7 @@ public PoolReaderSpi allocateReader(String readerGroupReference) throws PluginIO } throw new PluginIOException( - "No reader is available in the groupReference : " + readerGroupReference); + "No reader is available for the given group reference: " + readerGroupReference); } /** @@ -123,7 +123,7 @@ public void releaseReader(ReaderSpi readerSpi) { if (!(readerSpi instanceof StubReader)) { throw new IllegalArgumentException( - "Can not release reader, Reader should be of type StubReader"); + "Cannot cast 'readerSpi' to StubReader. Actual type: " + readerSpi.getClass().getName()); } allocatedReaders.remove(readerSpi.getName()); diff --git a/src/main/java/org/eclipse/keyple/plugin/stub/StubReaderAdapter.java b/src/main/java/org/eclipse/keyple/plugin/stub/StubReaderAdapter.java index f9d7552..7316dd1 100644 --- a/src/main/java/org/eclipse/keyple/plugin/stub/StubReaderAdapter.java +++ b/src/main/java/org/eclipse/keyple/plugin/stub/StubReaderAdapter.java @@ -73,7 +73,7 @@ final class StubReaderAdapter */ @Override public void onStartDetection() { - logger.info("Reader [{}]: card detection started", getName()); + // NOP } /** @@ -83,7 +83,7 @@ public void onStartDetection() { */ @Override public void onStopDetection() { - logger.info("Reader [{}]: card detection stopped", getName()); + // NOP } /** @@ -202,7 +202,7 @@ public String getPowerOnData() { @Override public byte[] transmitApdu(byte[] apduIn) throws CardIOException { if (smartCard == null) { - throw new CardIOException("No card available."); + throw new CardIOException("No card is available"); } return smartCard.processApdu(apduIn); } @@ -240,18 +240,19 @@ public void insertCard(StubSmartCard smartCard) { Assert.getInstance().notNull(smartCard, "smart card"); if (checkCardPresence()) { logger.warn( - "Reader [{}]: first remove the inserted card before inserting a new one", getName()); + "[readerExt={}] A card is already inserted. First remove the inserted card before inserting a new one", + getName()); return; } if (!activatedProtocols.contains(smartCard.getCardProtocol())) { logger.info( - "Reader [{}]: inserted card protocol [{}] does not match any activated protocol, please use activateProtocol() method first", + "[readerExt={}] Inserted card protocol does not match any activated protocol. Please use 'activateProtocol()' method first [cardProtocol={}]", getName(), smartCard.getCardProtocol()); return; } if (logger.isTraceEnabled()) { - logger.trace("Reader [{}]: card inserted: {}", getName(), smartCard); + logger.trace("[readerExt={}] Card inserted [smartCard={}]", getName(), smartCard); } this.smartCard = smartCard; } @@ -265,7 +266,7 @@ public void insertCard(StubSmartCard smartCard) { public void removeCard() { if (smartCard != null) { if (logger.isTraceEnabled()) { - logger.trace("Reader [{}]: card removed: {}", getName(), smartCard); + logger.trace("[readerExt={}] Card removed [smartCard={}]", getName(), smartCard); } closePhysicalChannel(); this.smartCard = null; diff --git a/src/main/java/org/eclipse/keyple/plugin/stub/StubSmartCard.java b/src/main/java/org/eclipse/keyple/plugin/stub/StubSmartCard.java index e597478..326ee2d 100644 --- a/src/main/java/org/eclipse/keyple/plugin/stub/StubSmartCard.java +++ b/src/main/java/org/eclipse/keyple/plugin/stub/StubSmartCard.java @@ -143,7 +143,7 @@ byte[] processApdu(byte[] apduIn) throws CardIOException { } // throw a CardIOException if not found - throw new CardIOException("No response available for this request: " + hexApdu); + throw new CardIOException("No response is available for request: " + hexApdu); } /**