From 6e1ee6a5d48240511133ef079d05583ca94de21a Mon Sep 17 00:00:00 2001 From: erict875 Date: Mon, 6 Oct 2025 03:06:55 +0100 Subject: [PATCH 1/5] fix(logging): improve error messages and log levels per Clean Code guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit High-priority logging fixes based on comprehensive code review: 1. Fixed empty error message in UserProfile.java - Added descriptive error message and context to exception - Now properly describes Bech32 conversion failure 2. Improved generic warning in GenericEvent.java - Changed from log.warn(ex.getMessage()) to include full context - Added exception stacktrace for better debugging - Message now explains serialization failure context 3. Optimized expensive debug logging in GenericEvent.java - Changed serialized event logging from DEBUG to TRACE level - Added guard with log.isTraceEnabled() to prevent unnecessary String creation - Reduces performance overhead when TRACE is disabled 4. Fixed inappropriate INFO level in GenericTagDecoder.java - Changed log.info to log.debug for routine decoding operation - INFO should be for noteworthy events, not expected operations 5. Added comprehensive LOGGING_REVIEW.md - Documents all logging practices against Clean Code principles - Identifies 8 priority levels of improvements - Overall grade: B+ (will be A- after all high-priority fixes) Compliance with Clean Code chapters 2, 3, 4, 7, 10, 17: - Meaningful error messages (Ch 2: Meaningful Names) - Proper context in logs (Ch 4: Comments) - Better error handling (Ch 7: Error Handling) - Reduced code smells (Ch 17: Smells and Heuristics) Ref: LOGGING_REVIEW.md for complete analysis and remaining action items πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- LOGGING_REVIEW.md | 377 ++++++++++++++++++ .../nostr/event/entities/UserProfile.java | 4 +- .../java/nostr/event/impl/GenericEvent.java | 6 +- .../event/json/codec/GenericTagDecoder.java | 2 +- 4 files changed, 384 insertions(+), 5 deletions(-) create mode 100644 LOGGING_REVIEW.md diff --git a/LOGGING_REVIEW.md b/LOGGING_REVIEW.md new file mode 100644 index 00000000..cd895263 --- /dev/null +++ b/LOGGING_REVIEW.md @@ -0,0 +1,377 @@ +# Logging Review - Clean Code Compliance + +**Date**: 2025-10-06 +**Reviewer**: Claude Code +**Guidelines**: Clean Code principles (Chapters 2, 3, 4, 7, 10, 17) + +## Executive Summary + +The nostr-java codebase uses SLF4J logging with Lombok's `@Slf4j` annotation consistently across the project. The logging implementation is generally good, with proper log levels and meaningful messages. However, there are several areas where the logging does not fully comply with Clean Code principles. + +**Overall Grade**: B+ + +**Key Findings**: +- βœ… Consistent use of SLF4J with Lombok `@Slf4j` +- βœ… No sensitive data (private keys, passwords) logged in plain text +- βœ… Appropriate log levels used in most cases +- ⚠️ Some empty or non-descriptive error messages +- ⚠️ Excessive debug logging in low-level classes (PrivateKey, PublicKey) +- ⚠️ Test methods using log.info for test names (should use JUnit display names) +- ⚠️ Some log messages lack context + +## Detailed Findings + +### 1. Clean Code Chapter 2: Meaningful Names + +**Principle**: Use intention-revealing, searchable names in log messages. + +#### Issues Found + +**❌ Empty error message** (`nostr-java-event/src/main/java/nostr/event/entities/UserProfile.java:46`) +```java +log.error("", ex); +``` + +**Problem**: Empty string provides no context about what failed. +**Fix**: Add meaningful error message +```java +log.error("Failed to encode UserProfile to Bech32 format", ex); +``` + +**❌ Generic warning** (`nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java:196`) +```java +log.warn(ex.getMessage()); +``` + +**Problem**: Only logs exception message without context about what operation failed. +**Fix**: Add context +```java +log.warn("Failed to update event during serialization: {}", ex.getMessage(), ex); +``` + +### 2. Clean Code Chapter 3: Functions + +**Principle**: Functions should do one thing. Logging should not be the primary purpose. + +#### Issues Found + +**⚠️ Excessive constructor logging** (`nostr-java-base/src/main/java/nostr/base/PrivateKey.java:16,21,29`) +```java +public PrivateKey(byte[] rawData) { + super(KeyType.PRIVATE, rawData, Bech32Prefix.NSEC); + log.debug("Created private key from byte array"); +} + +public PrivateKey(String hexPrivKey) { + super(KeyType.PRIVATE, NostrUtil.hexToBytes(hexPrivKey), Bech32Prefix.NSEC); + log.debug("Created private key from hex string"); +} + +public static PrivateKey generateRandomPrivKey() { + PrivateKey key = new PrivateKey(Schnorr.generatePrivateKey()); + log.debug("Generated new random private key"); + return key; +} +``` + +**Problem**: Low-level constructors should not log. This creates noise and violates single responsibility. These classes are used frequently, and logging every creation adds overhead. + +**Recommendation**: Remove these debug logs. If tracking object creation is needed, use a profiler or instrumentation. + +**Same issue in** `PublicKey.java:17,22` and `BaseKey.java:32,48` + +### 3. Clean Code Chapter 4: Comments + +**Principle**: Code should be self-documenting. Logs should not explain what code does, but provide runtime context. + +#### Good Examples + +**βœ… Context-rich logging** (`SpringWebSocketClient.java:38-42`) +```java +log.debug( + "Sending {} to relay {} (size={} bytes)", + eventMessage.getCommand(), + relayUrl, + json.length()); +``` + +**Good**: Provides runtime context (command, relay, size) without explaining code logic. + +**βœ… Error recovery logging** (`SpringWebSocketClient.java:112-116`) +```java +log.error( + "Failed to send message to relay {} after retries (size={} bytes)", + relayUrl, + json.length(), + ex); +``` + +**Good**: Logs failure with context and includes exception for debugging. + +#### Issues Found + +**⚠️ Verbose serialization logging** (`GenericEvent.java:277`) +```java +log.debug("Serialized event: {}", new String(this.get_serializedEvent())); +``` + +**Problem**: Logs entire serialized event at debug level. This could be very verbose and is called frequently. Consider: +1. Using TRACE level instead of DEBUG +2. Truncating output +3. Removing this log entirely (serialization is expected behavior) + +**Recommendation**: Remove or change to TRACE level with size limit. + +### 4. Clean Code Chapter 7: Error Handling + +**Principle**: Error handling should be complete. Don't pass null or empty messages to logging. + +#### Issues Found + +**❌ Empty error log** (`UserProfile.java:46`) +```java +catch (Exception ex) { + log.error("", ex); // Empty message + throw new RuntimeException(ex); +} +``` + +**Fix**: +```java +catch (Exception ex) { + log.error("Failed to convert UserProfile to Bech32 format", ex); + throw new RuntimeException("Failed to convert UserProfile to Bech32 format", ex); +} +``` + +**⚠️ Generic RuntimeException wrapping** (multiple locations) +```java +catch (Exception ex) { + log.error("Error converting key to Bech32", ex); + throw new RuntimeException(ex); +} +``` + +**Better approach**: Create specific exception types or include original message: +```java +catch (Exception ex) { + log.error("Error converting {} key to Bech32 format with prefix {}", type, prefix, ex); + throw new RuntimeException("Failed to convert key to Bech32: " + ex.getMessage(), ex); +} +``` + +### 5. Clean Code Chapter 10: Classes + +**Principle**: Classes should have a single responsibility. Excessive logging can indicate unclear responsibilities. + +#### Good Examples + +**βœ… Client handler logging** (`SpringWebSocketClient.java`) +- Logs connection lifecycle events +- Logs retry failures +- Logs subscription events +- All appropriate for a client handler class + +**βœ… Validator logging** (`Nip05Validator.java:110,123,133`) +- Logs validation errors with context +- Logs HTTP request failures +- Logs public key lookup results +- All appropriate for a validator class + +#### Issues Found + +**⚠️ Low-level utility logging** (`PrivateKey.java`, `PublicKey.java`, `BaseKey.java`) + +These classes are data containers with minimal behavior. Logging in constructors and conversion methods adds noise without value. + +**Recommendation**: Remove all debug logging from these low-level classes. If needed, add logging at the application layer where these objects are used. + +### 6. Clean Code Chapter 17: Smells and Heuristics + +**Principle**: Avoid code smells that indicate poor design. + +#### Code Smells Found + +**G5: Duplication** + +**⚠️ Duplicated recovery logging** (`SpringWebSocketClient.java:112-116, 129-133, 145-151, 166-171`) + +Four nearly identical recovery methods with duplicated logging logic. + +**Recommendation**: Extract common recovery logging: +```java +private void logRecoveryFailure(String operation, String relayUrl, int size, IOException ex) { + log.error("Failed to {} to relay {} after retries (size={} bytes)", + operation, relayUrl, size, ex); +} +``` + +**G15: Selector Arguments** + +Test classes use `log.info()` to log test names: +```java +@Test +void testEventFilterEncoder() { + log.info("testEventFilterEncoder"); // Unnecessary + // test code +} +``` + +**Recommendation**: Remove these. Use JUnit's `@DisplayName` instead: +```java +@Test +@DisplayName("Event filter encoder should serialize filters correctly") +void testEventFilterEncoder() { + // test code +} +``` + +**G31: Hidden Temporal Couplings** + +**⚠️ Potential issue** (`GenericTagDecoder.java:56`) +```java +log.info("Decoded GenericTag: {}", genericTag); +``` + +**Problem**: Using INFO level for routine decoding operation. This should be DEBUG or removed entirely. INFO level implies something noteworthy, but decoding is expected behavior. + +**Recommendation**: Change to DEBUG or remove. + +### 7. Security Concerns + +**βœ… No Sensitive Data Logged** + +Analysis of all logging statements confirms: +- Private keys are NOT logged (only existence is logged: "Created private key") +- Passwords/secrets are NOT logged +- Public keys are logged only at DEBUG level (appropriate since they're public) + +**Good security practice observed**. + +### 8. Performance Concerns + +**⚠️ Expensive Operations at DEBUG Level** + +Several locations log expensive operations: + +1. **Full event serialization** (`GenericEvent.java:277`) +```java +log.debug("Serialized event: {}", new String(this.get_serializedEvent())); +``` + +2. **GenericTag decoding** (`GenericTagDecoder.java:56`) +```java +log.info("Decoded GenericTag: {}", genericTag); +``` + +**Problem**: Even if DEBUG is disabled, `toString()` is still called on objects passed to log methods. + +**Recommendation**: Use lazy evaluation: +```java +if (log.isDebugEnabled()) { + log.debug("Serialized event: {}", new String(this.get_serializedEvent())); +} +``` + +Or better, remove entirely. + +## Recommendations by Priority + +### High Priority (Fix Immediately) + +1. **Fix empty error message** in `UserProfile.java:46` + ```java + // Before + log.error("", ex); + + // After + log.error("Failed to convert UserProfile to Bech32 format", ex); + ``` + +2. **Fix generic warning** in `GenericEvent.java:196` + ```java + // Before + log.warn(ex.getMessage()); + + // After + log.warn("Failed to update event during serialization: {}", ex.getMessage(), ex); + ``` + +3. **Change INFO to DEBUG** in `GenericTagDecoder.java:56` + ```java + // Before + log.info("Decoded GenericTag: {}", genericTag); + + // After + log.debug("Decoded GenericTag: {}", genericTag); + // Or remove entirely + ``` + +### Medium Priority (Should Fix) + +4. **Remove constructor logging** from `PrivateKey.java`, `PublicKey.java`, `BaseKey.java` + - Lines: `PrivateKey.java:16,21,29` + - Lines: `PublicKey.java:17,22` + - Lines: `BaseKey.java:32,48` + +5. **Remove or optimize expensive debug logging** + - `GenericEvent.java:277` - Full event serialization + - Add `if (log.isDebugEnabled())` guard or remove + +6. **Remove test method name logging** + - All files in `nostr-java-event/src/test/java/` + - Replace with `@DisplayName` annotations + +### Low Priority (Nice to Have) + +7. **Extract duplicated recovery logging** in `SpringWebSocketClient.java` + - Create helper method to reduce duplication + +8. **Add more context to error messages** + - Include variable values that help debugging + - Use structured logging where appropriate + +## Compliance Summary + +| Clean Code Chapter | Compliance | Issues | +|-------------------|------------|---------| +| Ch 2: Meaningful Names | 🟑 Partial | Empty error messages, generic warnings | +| Ch 3: Functions | 🟑 Partial | Constructor logging, excessive debug logs | +| Ch 4: Comments | βœ… Good | Most logs provide runtime context, not code explanation | +| Ch 7: Error Handling | 🟑 Partial | Empty error messages, generic exceptions | +| Ch 10: Classes | βœ… Good | Logging appropriate for class responsibilities (except low-level utils) | +| Ch 17: Smells | 🟑 Partial | Duplication, test name logging, INFO for routine operations | + +**Legend**: βœ… Good | 🟑 Partial | ❌ Poor + +## Positive Observations + +1. **Consistent framework usage**: SLF4J with Lombok `@Slf4j` throughout +2. **Proper log levels**: DEBUG for detailed info, ERROR for failures, WARN for issues +3. **Parameterized logging**: Uses `{}` placeholders (avoids string concatenation) +4. **Security**: No sensitive data logged +5. **Context-rich messages**: Most logs include relay URLs, subscription IDs, sizes +6. **Exception logging**: Properly includes exception objects in error logs + +## Action Items + +Create issues or tasks for: +- [ ] Fix empty error message in UserProfile.java +- [ ] Fix generic warning in GenericEvent.java +- [ ] Change INFO to DEBUG in GenericTagDecoder.java +- [ ] Remove constructor logging from key classes +- [ ] Optimize or remove expensive debug logging +- [ ] Replace test log.info with @DisplayName +- [ ] Extract duplicated recovery logging +- [ ] Review and enhance error message context + +## Conclusion + +The logging implementation in nostr-java is solid overall, with proper use of SLF4J and good security practices. The main areas for improvement are: + +1. **Meaningful error messages** (avoid empty strings) +2. **Reduce noise** (remove constructor logging in low-level classes) +3. **Optimize performance** (guard expensive debug operations) +4. **Improve tests** (use JUnit features instead of logging) + +Implementing the high-priority fixes will bring the codebase to an **A-** grade for logging practices. diff --git a/nostr-java-event/src/main/java/nostr/event/entities/UserProfile.java b/nostr-java-event/src/main/java/nostr/event/entities/UserProfile.java index 42c24f02..f8de4e27 100644 --- a/nostr-java-event/src/main/java/nostr/event/entities/UserProfile.java +++ b/nostr-java-event/src/main/java/nostr/event/entities/UserProfile.java @@ -43,8 +43,8 @@ public String toBech32() { return Bech32.encode( Bech32.Encoding.BECH32, Bech32Prefix.NPROFILE.getCode(), this.publicKey.getRawData()); } catch (Exception ex) { - log.error("", ex); - throw new RuntimeException(ex); + log.error("Failed to convert UserProfile to Bech32 format", ex); + throw new RuntimeException("Failed to convert UserProfile to Bech32 format", ex); } } diff --git a/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java index 772b1268..c9866051 100644 --- a/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java +++ b/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java @@ -193,7 +193,7 @@ public void update() { } catch (NostrException | NoSuchAlgorithmException ex) { throw new RuntimeException(ex); } catch (AssertionError ex) { - log.warn(ex.getMessage()); + log.warn("Failed to update event during serialization: {}", ex.getMessage(), ex); throw new RuntimeException(ex); } } @@ -274,7 +274,9 @@ public Consumer getSignatureConsumer() { @Override public Supplier getByteArraySupplier() { this.update(); - log.debug("Serialized event: {}", new String(this.get_serializedEvent())); + if (log.isTraceEnabled()) { + log.trace("Serialized event: {}", new String(this.get_serializedEvent())); + } return () -> ByteBuffer.wrap(this.get_serializedEvent()); } diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java b/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java index 3bf6f4dd..aedc7dbc 100644 --- a/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java +++ b/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java @@ -53,7 +53,7 @@ public T decode(@NonNull String json) throws EventEncodingException { } }); - log.info("Decoded GenericTag: {}", genericTag); + log.debug("Decoded GenericTag: {}", genericTag); return (T) genericTag; } catch (JsonProcessingException ex) { From 911ab87bee9f993e4e3ab2f640b53db8d6198329 Mon Sep 17 00:00:00 2001 From: erict875 Date: Mon, 6 Oct 2025 03:07:50 +0100 Subject: [PATCH 2/5] refactor(logging): remove constructor logging from low-level key classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Medium-priority logging improvements per Clean Code Chapter 3 (Functions): 1. Removed constructor logging from PrivateKey class - Removed "Created private key from byte array" debug log - Removed "Created private key from hex string" debug log - Removed "Generated new random private key" debug log - Simplified generateRandomPrivKey() to single return statement 2. Removed constructor logging from PublicKey class - Removed "Created public key from byte array" debug log - Removed "Created public key from hex string" debug log 3. Removed routine operation logging from BaseKey class - Removed "Converted key to Bech32" debug log in toBech32String() - Removed "Converted key to hex string" debug log in toHexString() - Simplified methods to single return statements 4. Enhanced error logging in BaseKey.toBech32String() - Added key type and prefix to error message for better context - Improved exception message to include original error Rationale: - Low-level data container classes should not log object creation - These classes are used frequently, logging creates noise - Constructor logging violates Single Responsibility Principle - If object creation tracking is needed, use profiler/instrumentation - Application layer should handle logging when appropriate Performance impact: - Reduces log overhead for frequently created objects - Eliminates unnecessary string formatting on every key creation Compliance: - Ch 3: Functions do one thing (no logging side effects) - Ch 10: Classes have single responsibility (data, not logging) - Ch 17: Eliminates logging "code smell" in utilities Ref: LOGGING_REVIEW.md sections 2, 5, and 8 πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/main/java/nostr/base/BaseKey.java | 12 ++++-------- .../src/main/java/nostr/base/PrivateKey.java | 6 +----- .../src/main/java/nostr/base/PublicKey.java | 2 -- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/nostr-java-base/src/main/java/nostr/base/BaseKey.java b/nostr-java-base/src/main/java/nostr/base/BaseKey.java index 9d058eaf..222dd4bf 100644 --- a/nostr-java-base/src/main/java/nostr/base/BaseKey.java +++ b/nostr-java-base/src/main/java/nostr/base/BaseKey.java @@ -28,12 +28,10 @@ public abstract class BaseKey implements IKey { @Override public String toBech32String() { try { - String bech32 = Bech32.toBech32(prefix, rawData); - log.debug("Converted key to Bech32 with prefix {}", prefix); - return bech32; + return Bech32.toBech32(prefix, rawData); } catch (Exception ex) { - log.error("Error converting key to Bech32", ex); - throw new RuntimeException(ex); + log.error("Failed to convert {} key to Bech32 format with prefix {}", type, prefix, ex); + throw new RuntimeException("Failed to convert key to Bech32: " + ex.getMessage(), ex); } } @@ -44,9 +42,7 @@ public String toString() { } public String toHexString() { - String hex = NostrUtil.bytesToHex(rawData); - log.debug("Converted key to hex string"); - return hex; + return NostrUtil.bytesToHex(rawData); } @Override diff --git a/nostr-java-base/src/main/java/nostr/base/PrivateKey.java b/nostr-java-base/src/main/java/nostr/base/PrivateKey.java index 3a86775d..39e3e7db 100644 --- a/nostr-java-base/src/main/java/nostr/base/PrivateKey.java +++ b/nostr-java-base/src/main/java/nostr/base/PrivateKey.java @@ -13,20 +13,16 @@ public class PrivateKey extends BaseKey { public PrivateKey(byte[] rawData) { super(KeyType.PRIVATE, rawData, Bech32Prefix.NSEC); - log.debug("Created private key from byte array"); } public PrivateKey(String hexPrivKey) { super(KeyType.PRIVATE, NostrUtil.hexToBytes(hexPrivKey), Bech32Prefix.NSEC); - log.debug("Created private key from hex string"); } /** * @return A strong pseudo random private key */ public static PrivateKey generateRandomPrivKey() { - PrivateKey key = new PrivateKey(Schnorr.generatePrivateKey()); - log.debug("Generated new random private key"); - return key; + return new PrivateKey(Schnorr.generatePrivateKey()); } } diff --git a/nostr-java-base/src/main/java/nostr/base/PublicKey.java b/nostr-java-base/src/main/java/nostr/base/PublicKey.java index 64badd7b..d56b3d30 100644 --- a/nostr-java-base/src/main/java/nostr/base/PublicKey.java +++ b/nostr-java-base/src/main/java/nostr/base/PublicKey.java @@ -14,11 +14,9 @@ public class PublicKey extends BaseKey { public PublicKey(byte[] rawData) { super(KeyType.PUBLIC, rawData, Bech32Prefix.NPUB); - log.debug("Created public key from byte array"); } public PublicKey(String hexPubKey) { super(KeyType.PUBLIC, NostrUtil.hexToBytes(hexPubKey), Bech32Prefix.NPUB); - log.debug("Created public key from hex string"); } } From 33270a7cf5f803845884f650ce3562603ed7696c Mon Sep 17 00:00:00 2001 From: erict875 Date: Mon, 6 Oct 2025 03:10:51 +0100 Subject: [PATCH 3/5] refactor(test): remove test method name logging per Clean Code guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Low-priority cleanup per LOGGING_REVIEW.md recommendations: Removed all log.info("testMethodName") statements from test files across the entire codebase (89 total removals): - nostr-java-event: 58 removals - nostr-java-api: 26 removals - nostr-java-id: 4 removals - nostr-java-util: 1 removal Rationale (Clean Code Ch 17: Code Smells - G15 Selector Arguments): - Test method names are already visible in JUnit test output - Logging test names adds noise without value - JUnit @DisplayName annotation is the proper way to add readable test names - Reduces unnecessary log output during test execution Example of proper approach (if needed): ```java @Test @DisplayName("Event filter encoder should serialize filters correctly") void testEventFilterEncoder() { // test code } ``` Performance impact: - Eliminates 89 unnecessary log calls during test execution - Cleaner test output Compliance: - Ch 17: Removes code smell (unnecessary logging in tests) - Ch 4: Tests are self-documenting without log statements Ref: LOGGING_REVIEW.md section 6 (Code Smells - G15) πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../java/nostr/api/unit/JsonParseTest.java | 25 ------------------- .../java/nostr/api/unit/NIP57ImplTest.java | 1 - .../unit/BaseMessageCommandMapperTest.java | 5 ---- .../event/unit/BaseMessageDecoderTest.java | 7 ------ .../nostr/event/unit/FiltersDecoderTest.java | 22 ---------------- .../nostr/event/unit/FiltersEncoderTest.java | 24 ------------------ .../src/test/java/nostr/id/EventTest.java | 3 --- .../java/nostr/id/ZapReceiptEventTest.java | 1 - .../test/java/nostr/util/NostrUtilTest.java | 1 - 9 files changed, 89 deletions(-) diff --git a/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java b/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java index 74d7dfbf..afb66a5c 100644 --- a/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java +++ b/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java @@ -64,7 +64,6 @@ public class JsonParseTest { @Test public void testBaseMessageDecoderEventFilter() throws JsonProcessingException { - log.info("testBaseMessageDecoderEventFilter"); String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; final String parseTarget = @@ -110,7 +109,6 @@ public void testBaseMessageDecoderEventFilter() throws JsonProcessingException { @Test public void testBaseMessageDecoderKindsAuthorsReferencedPublicKey() throws JsonProcessingException { - log.info("testBaseMessageDecoderKindsAuthorsReferencedPublicKey"); final String parseTarget = "[\"REQ\", " @@ -152,7 +150,6 @@ public void testBaseMessageDecoderKindsAuthorsReferencedPublicKey() @Test public void testBaseMessageDecoderKindsAuthorsReferencedEvents() throws JsonProcessingException { - log.info("testBaseMessageDecoderKindsAuthorsReferencedEvents"); final String parseTarget = "[\"REQ\", " @@ -193,7 +190,6 @@ public void testBaseMessageDecoderKindsAuthorsReferencedEvents() throws JsonProc @Test public void testBaseReqMessageDecoder() throws JsonProcessingException { - log.info("testBaseReqMessageDecoder"); var publicKey = Identity.generateRandomIdentity().getPublicKey(); @@ -227,7 +223,6 @@ public void testBaseReqMessageDecoder() throws JsonProcessingException { @Test public void testBaseEventMessageDecoder() throws JsonProcessingException { - log.info("testBaseEventMessageDecoder"); final String parseTarget = "[\"EVENT\",\"npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh\",{" @@ -253,7 +248,6 @@ public void testBaseEventMessageDecoder() throws JsonProcessingException { @Test public void testBaseEventMessageMarkerDecoder() throws JsonProcessingException { - log.info("testBaseEventMessageMarkerDecoder"); final String json = "[\"EVENT\",\"temp20230627\",{" @@ -280,7 +274,6 @@ public void testBaseEventMessageMarkerDecoder() throws JsonProcessingException { @Test public void testGenericTagDecoder() { - log.info("testGenericTagDecoder"); final String jsonString = "[\"saturn\", \"jetpack\", false]"; var tag = new GenericTagDecoder<>().decode(jsonString); @@ -296,7 +289,6 @@ public void testGenericTagDecoder() { @Test public void testClassifiedListingTagSerializer() throws JsonProcessingException { - log.info("testClassifiedListingSerializer"); final String classifiedListingEventJson = "{\"id\":\"28f2fc030e335d061f0b9d03ce0e2c7d1253e6fadb15d89bd47379a96b2c861a\",\"kind\":30402,\"content\":\"content" + " ipsum\"," @@ -411,7 +403,6 @@ public void testClassifiedListingTagSerializer() throws JsonProcessingException @Test public void testDeserializeTag() throws Exception { - log.info("testDeserializeTag"); String npubHex = new PublicKey( @@ -431,7 +422,6 @@ public void testDeserializeTag() throws Exception { @Test public void testDeserializeGenericTag() throws Exception { - log.info("testDeserializeGenericTag"); String npubHex = new PublicKey( Bech32.fromBech32( @@ -448,7 +438,6 @@ public void testDeserializeGenericTag() throws Exception { @Test public void testReqMessageFilterListSerializer() { - log.info("testReqMessageFilterListSerializer"); String new_geohash = "2vghde"; String second_geohash = "3abcde"; @@ -471,7 +460,6 @@ public void testReqMessageFilterListSerializer() { @Test public void testReqMessageGeohashTagDeserializer() throws JsonProcessingException { - log.info("testReqMessageGeohashTagDeserializer"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; String geohashKey = "#g"; @@ -491,7 +479,6 @@ public void testReqMessageGeohashTagDeserializer() throws JsonProcessingExceptio @Test public void testReqMessageGeohashFilterListDecoder() { - log.info("testReqMessageGeohashFilterListDecoder"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; String geohashKey = "#g"; @@ -527,7 +514,6 @@ public void testReqMessageGeohashFilterListDecoder() { @Test public void testReqMessageHashtagTagDeserializer() throws JsonProcessingException { - log.info("testReqMessageHashtagTagDeserializer"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; String hashtagKey = "#t"; @@ -547,7 +533,6 @@ public void testReqMessageHashtagTagDeserializer() throws JsonProcessingExceptio @Test public void testReqMessageHashtagTagFilterListDecoder() { - log.info("testReqMessageHashtagTagFilterListDecoder"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; String hashtagKey = "#t"; @@ -583,7 +568,6 @@ public void testReqMessageHashtagTagFilterListDecoder() { @Test public void testReqMessagePopulatedFilterDecoder() { - log.info("testReqMessagePopulatedFilterDecoder"); String subscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh"; String kind = "1"; @@ -641,7 +625,6 @@ public void testReqMessagePopulatedFilterDecoder() { @Test public void testReqMessagePopulatedListOfFiltersWithIdentityDecoder() throws JsonProcessingException { - log.info("testReqMessagePopulatedListOfFiltersWithIdentityDecoder"); String subscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh"; String kind = "1"; @@ -702,7 +685,6 @@ public void testReqMessagePopulatedListOfFiltersWithIdentityDecoder() @Test public void testReqMessagePopulatedListOfFiltersListDecoder() throws JsonProcessingException { - log.info("testReqMessagePopulatedListOfFiltersListDecoder"); String subscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh"; Integer kind = 1; @@ -759,7 +741,6 @@ public void testReqMessagePopulatedListOfFiltersListDecoder() throws JsonProcess @Test public void testReqMessagePopulatedListOfMultipleTypeFiltersListDecoder() throws JsonProcessingException { - log.info("testReqMessagePopulatedListOfFiltersListDecoder"); String subscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh"; String kind = "1"; @@ -806,7 +787,6 @@ public void testReqMessagePopulatedListOfMultipleTypeFiltersListDecoder() @Test public void testGenericTagQueryListDecoder() throws JsonProcessingException { - log.info("testReqMessagePopulatedListOfFiltersListDecoder"); String subscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujh"; String kind = "1"; @@ -884,7 +864,6 @@ public void testGenericTagQueryListDecoder() throws JsonProcessingException { @Test public void testReqMessageAddressableTagDeserializer() throws JsonProcessingException { - log.info("testReqMessageAddressableTagDeserializer"); Integer kind = 1; String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; @@ -914,7 +893,6 @@ public void testReqMessageAddressableTagDeserializer() throws JsonProcessingExce @Test public void testReqMessageSubscriptionIdTooLong() { - log.info("testReqMessageSubscriptionIdTooLong"); String malformedSubscriptionId = "npub17x6pn22ukq3n5yw5x9prksdyyu6ww9jle2ckpqwdprh3ey8qhe6stnpujhaa"; @@ -933,7 +911,6 @@ public void testReqMessageSubscriptionIdTooLong() { @Test public void testReqMessageSubscriptionIdTooShort() { - log.info("testReqMessageSubscriptionIdTooShort"); String malformedSubscriptionId = ""; final String parseTarget = @@ -951,7 +928,6 @@ public void testReqMessageSubscriptionIdTooShort() { @Test public void testBaseEventMessageDecoderMultipleFiltersJson() throws JsonProcessingException { - log.info("testBaseEventMessageDecoderMultipleFiltersJson"); final String eventJson = "[\"EVENT\",{\"content\":\"η›΄γ‚“η›΄γ‚“γͺγ„γ‚γ€‚γΎγ‚γˆγˆγ‹\",\"created_at\":1786199583," @@ -992,7 +968,6 @@ public void testBaseEventMessageDecoderMultipleFiltersJson() throws JsonProcessi @Test public void testReqMessageVoteTagFilterDecoder() { - log.info("testReqMessageVoteTagFilterDecoder"); String subscriptionId = "npub333k6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; String voteTagKey = "#v"; diff --git a/nostr-java-api/src/test/java/nostr/api/unit/NIP57ImplTest.java b/nostr-java-api/src/test/java/nostr/api/unit/NIP57ImplTest.java index fd8a4806..5c943ba3 100644 --- a/nostr-java-api/src/test/java/nostr/api/unit/NIP57ImplTest.java +++ b/nostr-java-api/src/test/java/nostr/api/unit/NIP57ImplTest.java @@ -21,7 +21,6 @@ public class NIP57ImplTest { @Test void testNIP57CreateZapRequestEventFactory() throws NostrException { - log.info("testNIP57CreateZapRequestEventFactories"); Identity sender = Identity.generateRandomIdentity(); List baseTags = new ArrayList<>(); diff --git a/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageCommandMapperTest.java b/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageCommandMapperTest.java index 7237691d..5426da91 100644 --- a/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageCommandMapperTest.java +++ b/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageCommandMapperTest.java @@ -24,7 +24,6 @@ public class BaseMessageCommandMapperTest { @Test public void testReqMessageDecoder() throws JsonProcessingException { - log.info("testReqMessageDecoder"); BaseMessage decode = new BaseMessageDecoder<>().decode(REQ_JSON); assertInstanceOf(ReqMessage.class, decode); @@ -32,7 +31,6 @@ public void testReqMessageDecoder() throws JsonProcessingException { @Test public void testReqMessageDecoderType() { - log.info("testReqMessageDecoderType"); assertDoesNotThrow( () -> { @@ -47,7 +45,6 @@ public void testReqMessageDecoderType() { @Test public void testReqMessageDecoderThrows() { - log.info("testReqMessageDecoderThrows"); assertThrows( ClassCastException.class, @@ -58,7 +55,6 @@ public void testReqMessageDecoderThrows() { @Test public void testReqMessageDecoderDoesNotThrow() { - log.info("testReqMessageDecoderDoesNotThrow"); assertDoesNotThrow( () -> { @@ -68,7 +64,6 @@ public void testReqMessageDecoderDoesNotThrow() { @Test public void testReqMessageDecoderThrows3() { - log.info("testReqMessageDecoderThrows"); assertThrows( ClassCastException.class, diff --git a/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageDecoderTest.java b/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageDecoderTest.java index e7712fe5..4b18911a 100644 --- a/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageDecoderTest.java +++ b/nostr-java-event/src/test/java/nostr/event/unit/BaseMessageDecoderTest.java @@ -33,7 +33,6 @@ public class BaseMessageDecoderTest { @Test void testReqMessageDecoder() throws JsonProcessingException { - log.info("testReqMessageDecoder"); BaseMessage decode = new BaseMessageDecoder<>().decode(REQ_JSON); assertInstanceOf(ReqMessage.class, decode); @@ -41,7 +40,6 @@ void testReqMessageDecoder() throws JsonProcessingException { @Test void testReqMessageDecoderType() { - log.info("testReqMessageDecoderType"); assertDoesNotThrow( () -> { @@ -56,7 +54,6 @@ void testReqMessageDecoderType() { @Test void testReqMessageDecoderThrows() { - log.info("testReqMessageDecoderThrows"); assertThrows( ClassCastException.class, @@ -67,7 +64,6 @@ void testReqMessageDecoderThrows() { @Test void testReqMessageDecoderDoesNotThrow() { - log.info("testReqMessageDecoderDoesNotThrow"); assertDoesNotThrow( () -> { @@ -77,7 +73,6 @@ void testReqMessageDecoderDoesNotThrow() { @Test void testReqMessageDecoderThrows3() { - log.info("testReqMessageDecoderThrows"); assertThrows( ClassCastException.class, @@ -88,7 +83,6 @@ void testReqMessageDecoderThrows3() { @Test void testInvalidMessageDecoder() { - log.info("testInvalidMessageDecoder"); assertThrows( IllegalArgumentException.class, @@ -99,7 +93,6 @@ void testInvalidMessageDecoder() { @Test void testMalformedJsonThrows() { - log.info("testMalformedJsonThrows"); assertThrows( IllegalArgumentException.class, diff --git a/nostr-java-event/src/test/java/nostr/event/unit/FiltersDecoderTest.java b/nostr-java-event/src/test/java/nostr/event/unit/FiltersDecoderTest.java index 080cdb7c..b9a1eed6 100644 --- a/nostr-java-event/src/test/java/nostr/event/unit/FiltersDecoderTest.java +++ b/nostr-java-event/src/test/java/nostr/event/unit/FiltersDecoderTest.java @@ -36,7 +36,6 @@ public class FiltersDecoderTest { @Test public void testEventFiltersDecoder() { - log.info("testEventFiltersDecoder"); String filterKey = "ids"; String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -49,7 +48,6 @@ public void testEventFiltersDecoder() { @Test public void testMultipleEventFiltersDecoder() { - log.info("testMultipleEventFiltersDecoder"); String filterKey = "ids"; String eventId1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -69,7 +67,6 @@ public void testMultipleEventFiltersDecoder() { @Test public void testAddressableTagFiltersDecoder() { - log.info("testAddressableTagFiltersDecoder"); Integer kind = 1; String author = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -90,7 +87,6 @@ public void testAddressableTagFiltersDecoder() { @Test public void testMultipleAddressableTagFiltersDecoder() { - log.info("testMultipleAddressableTagFiltersDecoder"); Integer kind1 = 1; String author1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -125,7 +121,6 @@ public void testMultipleAddressableTagFiltersDecoder() { @Test public void testKindFiltersDecoder() { - log.info("testKindFiltersDecoder"); String filterKey = KindFilter.FILTER_KEY; Kind kind = Kind.valueOf(1); @@ -138,7 +133,6 @@ public void testKindFiltersDecoder() { @Test public void testMultipleKindFiltersDecoder() { - log.info("testMultipleKindFiltersDecoder"); String filterKey = KindFilter.FILTER_KEY; Kind kind1 = Kind.valueOf(1); @@ -154,7 +148,6 @@ public void testMultipleKindFiltersDecoder() { @Test public void testIdentifierTagFilterDecoder() { - log.info("testIdentifierTagFilterDecoder"); String uuidValue1 = "UUID-1"; @@ -167,7 +160,6 @@ public void testIdentifierTagFilterDecoder() { @Test public void testMultipleIdentifierTagFilterDecoder() { - log.info("testMultipleIdentifierTagFilterDecoder"); String uuidValue1 = "UUID-1"; String uuidValue2 = "UUID-2"; @@ -186,7 +178,6 @@ public void testMultipleIdentifierTagFilterDecoder() { @Test public void testReferencedEventFilterDecoder() { - log.info("testReferencedEventFilterDecoder"); String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -198,7 +189,6 @@ public void testReferencedEventFilterDecoder() { @Test public void testMultipleReferencedEventFilterDecoder() { - log.info("testMultipleReferencedEventFilterDecoder"); String eventId1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String eventId2 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -216,7 +206,6 @@ public void testMultipleReferencedEventFilterDecoder() { @Test public void testReferencedPublicKeyFilterDecofder() { - log.info("testReferencedPublicKeyFilterDecoder"); String pubkeyString = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -230,7 +219,6 @@ public void testReferencedPublicKeyFilterDecofder() { @Test public void testMultipleReferencedPublicKeyFilterDecoder() { - log.info("testMultipleReferencedPublicKeyFilterDecoder"); String pubkeyString1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String pubkeyString2 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -249,7 +237,6 @@ public void testMultipleReferencedPublicKeyFilterDecoder() { @Test public void testGeohashTagFiltersDecoder() { - log.info("testGeohashTagFiltersDecoder"); String geohashKey = "#g"; String geohashValue = "2vghde"; @@ -263,7 +250,6 @@ public void testGeohashTagFiltersDecoder() { @Test public void testMultipleGeohashTagFiltersDecoder() { - log.info("testMultipleGeohashTagFiltersDecoder"); String geohashKey = "#g"; String geohashValue1 = "2vghde"; @@ -282,7 +268,6 @@ public void testMultipleGeohashTagFiltersDecoder() { @Test public void testHashtagTagFiltersDecoder() { - log.info("testHashtagTagFiltersDecoder"); String hashtagKey = "#t"; String hashtagValue = "2vghde"; @@ -296,7 +281,6 @@ public void testHashtagTagFiltersDecoder() { @Test public void testMultipleHashtagTagFiltersDecoder() { - log.info("testMultipleHashtagTagFiltersDecoder"); String hashtagKey = "#t"; String hashtagValue1 = "2vghde"; @@ -315,7 +299,6 @@ public void testMultipleHashtagTagFiltersDecoder() { @Test public void testGenericTagFiltersDecoder() { - log.info("testGenericTagFiltersDecoder"); String customTagKey = "#b"; String customTagValue = "2vghde"; @@ -331,7 +314,6 @@ public void testGenericTagFiltersDecoder() { @Test public void testMultipleGenericTagFiltersDecoder() { - log.info("testMultipleGenericTagFiltersDecoder"); String customTagKey = "#b"; String customTagValue1 = "2vghde"; @@ -351,7 +333,6 @@ public void testMultipleGenericTagFiltersDecoder() { @Test public void testSinceFiltersDecoder() { - log.info("testSinceFiltersDecoder"); Long since = Date.from(Instant.now()).getTime(); @@ -363,7 +344,6 @@ public void testSinceFiltersDecoder() { @Test public void testUntilFiltersDecoder() { - log.info("testUntilFiltersDecoder"); Long until = Date.from(Instant.now()).getTime(); @@ -375,7 +355,6 @@ public void testUntilFiltersDecoder() { @Test public void testDecoderMultipleFilterTypes() { - log.info("testDecoderMultipleFilterTypes"); String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; Kind kind = Kind.valueOf(1); @@ -401,7 +380,6 @@ public void testDecoderMultipleFilterTypes() { @Test public void testFailedAddressableTagMalformedSeparator() { - log.info("testFailedAddressableTagMalformedSeparator"); Integer kind = 1; String author = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; diff --git a/nostr-java-event/src/test/java/nostr/event/unit/FiltersEncoderTest.java b/nostr-java-event/src/test/java/nostr/event/unit/FiltersEncoderTest.java index 6669ee61..be74919e 100644 --- a/nostr-java-event/src/test/java/nostr/event/unit/FiltersEncoderTest.java +++ b/nostr-java-event/src/test/java/nostr/event/unit/FiltersEncoderTest.java @@ -40,7 +40,6 @@ public class FiltersEncoderTest { @Test public void testEventFilterEncoder() { - log.info("testEventFilterEncoder"); String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -53,7 +52,6 @@ public void testEventFilterEncoder() { @Test public void testMultipleEventFilterEncoder() { - log.info("testMultipleEventFilterEncoder"); String eventId1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String eventId2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -71,7 +69,6 @@ public void testMultipleEventFilterEncoder() { @Test public void testKindFiltersEncoder() { - log.info("testKindFiltersEncoder"); Kind kind = Kind.valueOf(1); FiltersEncoder encoder = new FiltersEncoder(new Filters(new KindFilter<>(kind))); @@ -82,7 +79,6 @@ public void testKindFiltersEncoder() { @Test public void testAuthorFilterEncoder() { - log.info("testAuthorFilterEncoder"); String pubKeyString = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; FiltersEncoder encoder = @@ -94,7 +90,6 @@ public void testAuthorFilterEncoder() { @Test public void testMultipleAuthorFilterEncoder() { - log.info("testMultipleAuthorFilterEncoder"); String pubKeyString1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String pubKeyString2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -113,7 +108,6 @@ public void testMultipleAuthorFilterEncoder() { @Test public void testMultipleKindFiltersEncoder() { - log.info("testMultipleKindFiltersEncoder"); Kind kind1 = Kind.valueOf(1); Kind kind2 = Kind.valueOf(2); @@ -128,7 +122,6 @@ public void testMultipleKindFiltersEncoder() { @Test public void testAddressableTagFilterEncoder() { - log.info("testAddressableTagFilterEncoder"); Integer kind = 1; String author = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -148,7 +141,6 @@ public void testAddressableTagFilterEncoder() { @Test public void testIdentifierTagFilterEncoder() { - log.info("testIdentifierTagFilterEncoder"); String uuidValue1 = "UUID-1"; @@ -160,7 +152,6 @@ public void testIdentifierTagFilterEncoder() { @Test public void testMultipleIdentifierTagFilterEncoder() { - log.info("testMultipleIdentifierTagFilterEncoder"); String uuidValue1 = "UUID-1"; String uuidValue2 = "UUID-2"; @@ -179,7 +170,6 @@ public void testMultipleIdentifierTagFilterEncoder() { @Test public void testReferencedEventFilterEncoder() { - log.info("testReferencedEventFilterEncoder"); String eventId = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -191,7 +181,6 @@ public void testReferencedEventFilterEncoder() { @Test public void testMultipleReferencedEventFilterEncoder() { - log.info("testMultipleReferencedEventFilterEncoder"); String eventId1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String eventId2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -210,7 +199,6 @@ public void testMultipleReferencedEventFilterEncoder() { @Test public void testReferencedPublicKeyFilterEncoder() { - log.info("testReferencedPublicKeyFilterEncoder"); String pubKeyString = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -225,7 +213,6 @@ public void testReferencedPublicKeyFilterEncoder() { @Test public void testMultipleReferencedPublicKeyFilterEncoder() { - log.info("testMultipleReferencedPublicKeyFilterEncoder"); String pubKeyString1 = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; String pubKeyString2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -243,7 +230,6 @@ public void testMultipleReferencedPublicKeyFilterEncoder() { @Test public void testSingleGeohashTagFiltersEncoder() { - log.info("testSingleGeohashTagFiltersEncoder"); String new_geohash = "2vghde"; @@ -256,7 +242,6 @@ public void testSingleGeohashTagFiltersEncoder() { @Test public void testMultipleGeohashTagFiltersEncoder() { - log.info("testMultipleGenericTagFiltersEncoder"); String geohashValue1 = "2vghde"; String geohashValue2 = "3abcde"; @@ -273,7 +258,6 @@ public void testMultipleGeohashTagFiltersEncoder() { @Test public void testSingleHashtagTagFiltersEncoder() { - log.info("testSingleHashtagTagFiltersEncoder"); String hashtag_target = "2vghde"; @@ -286,7 +270,6 @@ public void testSingleHashtagTagFiltersEncoder() { @Test public void testMultipleHashtagTagFiltersEncoder() { - log.info("testMultipleHashtagTagFiltersEncoder"); String hashtagValue1 = "2vghde"; String hashtagValue2 = "3abcde"; @@ -303,7 +286,6 @@ public void testMultipleHashtagTagFiltersEncoder() { @Test public void testSingleCustomGenericTagQueryFiltersEncoder() { - log.info("testSingleCustomGenericTagQueryFiltersEncoder"); String customKey = "#b"; String customValue = "2vghde"; @@ -318,7 +300,6 @@ public void testSingleCustomGenericTagQueryFiltersEncoder() { @Test public void testMultipleCustomGenericTagQueryFiltersEncoder() { - log.info("testMultipleCustomGenericTagQueryFiltersEncoder"); String customKey = "#b"; String customValue1 = "2vghde"; @@ -336,7 +317,6 @@ public void testMultipleCustomGenericTagQueryFiltersEncoder() { @Test public void testMultipleAddressableTagFilterEncoder() { - log.info("testMultipleAddressableTagFilterEncoder"); Integer kind = 1; String author = "f1b419a95cb0233a11d431423b41a42734e7165fcab16081cd08ef1c90e0be75"; @@ -367,7 +347,6 @@ public void testMultipleAddressableTagFilterEncoder() { @Test public void testSinceFiltersEncoder() { - log.info("testSinceFiltersEncoder"); Long since = Date.from(Instant.now()).getTime(); @@ -378,7 +357,6 @@ public void testSinceFiltersEncoder() { @Test public void testUntilFiltersEncoder() { - log.info("testUntilFiltersEncoder"); Long until = Date.from(Instant.now()).getTime(); @@ -389,7 +367,6 @@ public void testUntilFiltersEncoder() { @Test public void testReqMessageEmptyFilters() { - log.info("testReqMessageEmptyFilters"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; assertThrows( @@ -399,7 +376,6 @@ public void testReqMessageEmptyFilters() { @Test public void testReqMessageCustomGenericTagFilter() { - log.info("testReqMessageEmptyFilterKey"); String subscriptionId = "npub1clk6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9"; assertDoesNotThrow( diff --git a/nostr-java-id/src/test/java/nostr/id/EventTest.java b/nostr-java-id/src/test/java/nostr/id/EventTest.java index f614152d..719c9a81 100644 --- a/nostr-java-id/src/test/java/nostr/id/EventTest.java +++ b/nostr-java-id/src/test/java/nostr/id/EventTest.java @@ -34,7 +34,6 @@ public EventTest() {} @Test public void testCreateTextNoteEvent() { - log.info("testCreateTextNoteEvent"); PublicKey publicKey = Identity.generateRandomIdentity().getPublicKey(); GenericEvent instance = EntityFactory.Events.createTextNoteEvent(publicKey); instance.update(); @@ -51,7 +50,6 @@ public void testCreateTextNoteEvent() { @Test public void testCreateGenericTag() { - log.info("testCreateGenericTag"); PublicKey publicKey = Identity.generateRandomIdentity().getPublicKey(); GenericTag genericTag = EntityFactory.Events.createGenericTag(publicKey); @@ -104,7 +102,6 @@ public void testAuthMessage() { @Test public void testEventIdConstraints() { - log.info("testCreateTextNoteEvent"); PublicKey publicKey = Identity.generateRandomIdentity().getPublicKey(); GenericEvent genericEvent = EntityFactory.Events.createTextNoteEvent(publicKey); String id64chars = "fc7f200c5bed175702bd06c7ca5dba90d3497e827350b42fc99c3a4fa276a712"; diff --git a/nostr-java-id/src/test/java/nostr/id/ZapReceiptEventTest.java b/nostr-java-id/src/test/java/nostr/id/ZapReceiptEventTest.java index fbb663ef..bc22f814 100644 --- a/nostr-java-id/src/test/java/nostr/id/ZapReceiptEventTest.java +++ b/nostr-java-id/src/test/java/nostr/id/ZapReceiptEventTest.java @@ -9,7 +9,6 @@ class ZapReceiptEventTest { @Test void testConstructZapReceiptEvent() { - log.info("testConstructZapReceiptEvent"); PublicKey sender = Identity.generateRandomIdentity().getPublicKey(); String zapRequestPubKeyTag = Identity.generateRandomIdentity().getPublicKey().toString(); diff --git a/nostr-java-util/src/test/java/nostr/util/NostrUtilTest.java b/nostr-java-util/src/test/java/nostr/util/NostrUtilTest.java index 8560f3ac..f9eb3693 100644 --- a/nostr-java-util/src/test/java/nostr/util/NostrUtilTest.java +++ b/nostr-java-util/src/test/java/nostr/util/NostrUtilTest.java @@ -16,7 +16,6 @@ public class NostrUtilTest { */ @Test public void testHexToBytesHex() { - log.info("testHexToBytesHex"); String pubKeyString = "56adf01ca1aa9d6f1c35953833bbe6d99a0c85b73af222e6bd305b51f2749f6f"; assertEquals( pubKeyString, From 337bce4ff33de62a6bff2cfd25468f26ee19e259 Mon Sep 17 00:00:00 2001 From: erict875 Date: Mon, 6 Oct 2025 03:11:59 +0100 Subject: [PATCH 4/5] refactor(logging): extract duplicated recovery logging in SpringWebSocketClient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Low-priority refactoring per LOGGING_REVIEW.md recommendations: Extracted duplicated recovery logging into reusable helper methods: 1. Added logRecoveryFailure(String operation, int size, IOException ex) - Handles simple recovery failures (send message, subscribe) - Reduces duplication in recover() and recoverSubscription() methods 2. Added logRecoveryFailure(String operation, String command, int size, IOException ex) - Handles recovery failures with command context - Used for BaseMessage recovery methods Benefits: - Reduces code duplication (4 nearly identical log statements β†’ 2 helper methods) - Makes recovery logging consistent across all methods - Easier to maintain and update logging format in one place - Follows DRY (Don't Repeat Yourself) principle Compliance: - Ch 17: Eliminates code smell (G5 - Duplication) - Ch 3: Functions do one thing (separate logging concern) - Ch 10: Single Responsibility (logging extracted to helper) Before: 4 duplicated log.error() calls with similar patterns After: 2 reusable helper methods, 4 one-line calls Ref: LOGGING_REVIEW.md section 6 (Code Smells - G5) πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../SpringWebSocketClient.java | 60 ++++++++++++------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/nostr-java-client/src/main/java/nostr/client/springwebsocket/SpringWebSocketClient.java b/nostr-java-client/src/main/java/nostr/client/springwebsocket/SpringWebSocketClient.java index 780550f1..ba8d043e 100644 --- a/nostr-java-client/src/main/java/nostr/client/springwebsocket/SpringWebSocketClient.java +++ b/nostr-java-client/src/main/java/nostr/client/springwebsocket/SpringWebSocketClient.java @@ -98,6 +98,40 @@ public AutoCloseable subscribe( return handle; } + /** + * Logs a recovery failure with operation context. + * + * @param operation the operation that failed (e.g., "send message", "subscribe") + * @param size the size of the message in bytes + * @param ex the exception that caused the failure + */ + private void logRecoveryFailure(String operation, int size, IOException ex) { + log.error( + "Failed to {} to relay {} after retries (size={} bytes)", + operation, + relayUrl, + size, + ex); + } + + /** + * Logs a recovery failure with operation and command context. + * + * @param operation the operation that failed (e.g., "send", "subscribe with") + * @param command the command type from the message + * @param size the size of the message in bytes + * @param ex the exception that caused the failure + */ + private void logRecoveryFailure(String operation, String command, int size, IOException ex) { + log.error( + "Failed to {} {} to relay {} after retries (size={} bytes)", + operation, + command, + relayUrl, + size, + ex); + } + /** * This method is invoked by Spring Retry after all retry attempts for the {@link #send(String)} * method are exhausted. It logs the failure and rethrows the exception. @@ -109,11 +143,7 @@ public AutoCloseable subscribe( */ @Recover public List recover(IOException ex, String json) throws IOException { - log.error( - "Failed to send message to relay {} after retries (size={} bytes)", - relayUrl, - json.length(), - ex); + logRecoveryFailure("send message", json.length(), ex); throw ex; } @@ -125,11 +155,7 @@ public AutoCloseable recoverSubscription( Consumer errorListener, Runnable closeListener) throws IOException { - log.error( - "Failed to subscribe with raw message to relay {} after retries (size={} bytes)", - relayUrl, - json.length(), - ex); + logRecoveryFailure("subscribe with raw message", json.length(), ex); throw ex; } @@ -142,12 +168,7 @@ public AutoCloseable recoverSubscription( Runnable closeListener) throws IOException { String json = requestMessage.encode(); - log.error( - "Failed to subscribe with {} to relay {} after retries (size={} bytes)", - requestMessage.getCommand(), - relayUrl, - json.length(), - ex); + logRecoveryFailure("subscribe with", requestMessage.getCommand(), json.length(), ex); throw ex; } @@ -163,12 +184,7 @@ public AutoCloseable recoverSubscription( @Recover public List recover(IOException ex, BaseMessage eventMessage) throws IOException { String json = eventMessage.encode(); - log.error( - "Failed to send {} to relay {} after retries (size={} bytes)", - eventMessage.getCommand(), - relayUrl, - json.length(), - ex); + logRecoveryFailure("send", eventMessage.getCommand(), json.length(), ex); throw ex; } From 90a4c8b8afa04ba268a35c54d6f874c485c4ff61 Mon Sep 17 00:00:00 2001 From: erict875 Date: Mon, 6 Oct 2025 03:14:00 +0100 Subject: [PATCH 5/5] chore: bump version to 0.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update version from 0.6.0 to 0.6.1 across all modules: - Root pom.xml (project version and nostr-java.version property) - All 9 module pom.xml files Changes in this release: - Fixed empty error messages and improved log context - Removed constructor logging from low-level key classes - Optimized expensive debug logging with guards - Fixed inappropriate log levels (INFO β†’ DEBUG where needed) - Removed 89 test method name log statements - Extracted duplicated recovery logging Logging compliance improved from B+ to A- per Clean Code guidelines. Ref: LOGGING_REVIEW.md for complete analysis πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- nostr-java-api/pom.xml | 2 +- nostr-java-base/pom.xml | 2 +- nostr-java-client/pom.xml | 2 +- nostr-java-crypto/pom.xml | 2 +- nostr-java-encryption/pom.xml | 2 +- nostr-java-event/pom.xml | 2 +- nostr-java-examples/pom.xml | 2 +- nostr-java-id/pom.xml | 2 +- nostr-java-util/pom.xml | 2 +- pom.xml | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nostr-java-api/pom.xml b/nostr-java-api/pom.xml index 92a92008..3efef71a 100644 --- a/nostr-java-api/pom.xml +++ b/nostr-java-api/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-base/pom.xml b/nostr-java-base/pom.xml index 31677805..3178eebf 100644 --- a/nostr-java-base/pom.xml +++ b/nostr-java-base/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-client/pom.xml b/nostr-java-client/pom.xml index 2481b1fc..f1228049 100644 --- a/nostr-java-client/pom.xml +++ b/nostr-java-client/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-crypto/pom.xml b/nostr-java-crypto/pom.xml index 5b8f6895..2cbdebd7 100644 --- a/nostr-java-crypto/pom.xml +++ b/nostr-java-crypto/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-encryption/pom.xml b/nostr-java-encryption/pom.xml index 1c89cd3c..d14b48b6 100644 --- a/nostr-java-encryption/pom.xml +++ b/nostr-java-encryption/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-event/pom.xml b/nostr-java-event/pom.xml index 094b7348..5d2754ba 100644 --- a/nostr-java-event/pom.xml +++ b/nostr-java-event/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-examples/pom.xml b/nostr-java-examples/pom.xml index 212ee0e5..b0d84933 100644 --- a/nostr-java-examples/pom.xml +++ b/nostr-java-examples/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-id/pom.xml b/nostr-java-id/pom.xml index 7d30cb55..d9587aa6 100644 --- a/nostr-java-id/pom.xml +++ b/nostr-java-id/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/nostr-java-util/pom.xml b/nostr-java-util/pom.xml index 9e6c1d47..02251669 100644 --- a/nostr-java-util/pom.xml +++ b/nostr-java-util/pom.xml @@ -4,7 +4,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 ../pom.xml diff --git a/pom.xml b/pom.xml index fbae05b1..2ad7e237 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xyz.tcheeric nostr-java - 0.6.0 + 0.6.1 pom ${project.artifactId} @@ -75,7 +75,7 @@ 1.1.1 - 0.6.0 + 0.6.1 0.8.0