Skip to content

Optimize BaseMessageDecoder parsing - #221

Merged
tcheeric merged 3 commits into
developfrom
codex/refactor-validateproperlyformedjson-in-basemessagedecoder
Jul 29, 2025
Merged

tcheeric merged 3 commits into
developfrom
codex/refactor-validateproperlyformedjson-in-basemessagedecoder

Conversation

@tcheeric

Copy link
Copy Markdown
Owner

Summary

  • avoid double JSON parsing in BaseMessageDecoder.validateProperlyFormedJson
  • hold JsonNode locally and reuse fields

Testing

  • mvn -q verify

https://chatgpt.com/codex/tasks/task_b_6889086edd408331a62c294fa7a23485

This comment was marked as outdated.

@tcheeric
tcheeric requested a review from Copilot July 29, 2025 18:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the BaseMessageDecoder class by eliminating redundant JSON parsing operations. The optimization caches the parsed JsonNode locally to avoid parsing the same JSON string multiple times within the validation method.

  • Replaces double JSON parsing with single parse operation in validateProperlyFormedJson
  • Adds null checks for JSON structure validation
  • Includes test coverage for malformed JSON handling

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
BaseMessageDecoder.java Optimizes JSON parsing by caching JsonNode and adds null validation for command/arg nodes
BaseMessageDecoderTest.java Adds test case for malformed JSON structure validation

Comment thread nostr-java-event/src/main/java/nostr/event/json/codec/BaseMessageDecoder.java Outdated
…ageDecoder.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tcheeric
tcheeric merged commit 81b9d78 into develop Jul 29, 2025
@tcheeric
tcheeric deleted the codex/refactor-validateproperlyformedjson-in-basemessagedecoder branch July 29, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants