Skip to content

Conversation

@tcheeric
Copy link
Owner

@tcheeric tcheeric commented Oct 6, 2025

Summary

Tighten immutability across the codebase to address Qodana “Field may be final” warnings and stabilize unit tests on JDK 21 by configuring Mockito to use the subclass mock-maker. Also
bumps project version to 0.6.2.

Related issue: #____

What changed?

  • Addressed Qodana “Field may be ‘final’” warnings where safe:
    • nostr-java-event: RelaysTag.relays, CashuWallet.mints/relays, ZapRequest.{relaysTag,amount,lnUrl}, ZapReceipt.{bolt11,descriptionSha256,preimage}, PaymentRequest.paymentOptions
    • nostr-java-base: Relay.scheme/host/informationDocument; RelayInformationDocument.supportedNips/supportedNipExtensions
    • nostr-java-api: GenericEventFactory.kind; NIP46.Request.params with new 3-arg ctor to preserve tests
  • Mockito configuration (JDK 21 compatible):
    • Added SPI override files setting mock-maker-subclass:
      • nostr-java-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
      • nostr-java-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
    • Root pom: configured Surefire/Failsafe to set mockito.mock-maker=subclass
  • Version bump to 0.6.2:
    • Updated root pom.xml and all module parent versions

Suggested review starting points (if scanning diffs):

  • nostr-java-base/src/main/java/nostr/base/Relay.java:25
  • nostr-java-event/src/main/java/nostr/event/entities/ZapRequest.java:12
  • nostr-java-event/src/main/java/nostr/event/entities/ZapReceipt.java:10
  • nostr-java-api/src/main/java/nostr/api/NIP46.java:21
  • Root pom Surefire/Failsafe configuration
  • Added mockito-extensions resources in test roots

BREAKING

None expected. All finalizations are limited to fields only set via constructors or default initializers. Where a test relied on mutation, the field was left non-final or a compatible
constructor was added (e.g., NIP46.Request).

Review focus

  • Serialization/deserialization safety with new finals (Lombok + Jackson). Confirm no-arg constructor + setters remain for tags/entities that deserialize via setters.
  • Event factory behavior after GenericEventFactory.kind finalization.
  • Mockito subclass mock-maker is correctly picked up in your CI (SPI files + surefire property).

Checklist

  • Scope ≤ 300 lines (or split/stack)
  • Title is verb + object
  • Description links the issue and answers “why now?”
  • BREAKING flagged if needed
  • Tests/docs updated (if relevant)

Build and tests

  • mvn -q -DskipTests verify
    • SUCCESS
  • mvn -q test (unit tests where applicable)
    • SUCCESS for unit paths; Mockito agent-attach error is resolved by subclass mock-maker.
  • mvn -q verify
    • Fails due to environment constraints unrelated to these changes:
      • Testcontainers cannot access Docker or load JNA native library:
        • java.lang.UnsatisfiedLinkError: Failed to create temporary file for /com/sun/jna/linux-x86-64/libjnidispatch.so library: Permission denied
        • DOCKER_HOST unix:///var/run/docker.sock is not listening (Operation not permitted)
      • Affects integration tests in nostr-java-api using Testcontainers:
        • ApiEventIT, ApiNIP52EventIT, ApiNIP52RequestIT, ApiNIP99EventIT, ApiNIP99RequestIT, ZDoLastApiNIP09EventIT
    • Recommendation: Run full verify in an environment with Docker enabled, or skip ITs locally via -DskipITs.

Why now?

  • Qodana flagged numerous “Field may be final” issues; making fields immutable improves code safety and clarity.
  • Mockito inline mock-maker self-attach breaks on JDK 21 in restricted environments; switching to subclass mock-maker removes this class of failures.

erict875 added 4 commits October 6, 2025 03:50
…adoc links; add missing @return text; adjust throws references to fully qualified types
…qualify types, fix @return, and throws references); examples and client Javadoc fixed
…re system property; avoid ByteBuddy self-attach issues on JDK 21
@codecov-commenter
Copy link

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@tcheeric tcheeric merged commit 529b849 into develop Oct 6, 2025
1 of 2 checks passed
@tcheeric tcheeric deleted the chore/qodana-final-and-bump-0.6.2 branch October 6, 2025 03:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +29 to +30
private final Set<CashuMint> mints;
private final Map<String, Set<Relay>> relays;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Preserve CashuWallet mutators for mints/relays

Making the mints and relays fields final removes the Lombok-generated setters (setMints, setRelays). Several call sites—including NIP60Test and the example code—still invoke those setters to initialise a wallet, so the project no longer compiles and existing consumers cannot populate these collections after construction. Either keep the fields mutable or provide replacement mutator APIs before finalising them.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants