Skip to content

QFJ-1283 Deduplicate checksum calculation - #1309

Open
kangdaeun1022 wants to merge 2 commits into
quickfix-j:masterfrom
kangdaeun1022:fix/1283-deduplicate-checksum-calculation
Open

QFJ-1283 Deduplicate checksum calculation#1309
kangdaeun1022 wants to merge 2 commits into
quickfix-j:masterfrom
kangdaeun1022:fix/1283-deduplicate-checksum-calculation

Conversation

@kangdaeun1022

@kangdaeun1022 kangdaeun1022 commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • centralize the string-equivalent checksum loop in MessageUtils
  • reuse the allocation-free CharSequence path from Message#setChecksum and FieldMap#calculateChecksum
  • preserve byte-based checksum calculation for multibyte charsets
  • add regression coverage for the StringBuilder fast path, UTF-8 encoded bytes, and repeating-group checksum consistency

Optimization rationale

The shared helper accepts CharSequence, so Message#setChecksum operates directly on its existing StringBuilder without creating a String or byte[]. String-equivalent charsets continue to use direct character traversal, while non-string-equivalent charsets continue to calculate the checksum from encoded bytes.

Testing

  • ./mvnw -pl quickfixj-base -Dtest=FieldMapTest,MessageUtilsTest test -Dmaven.javadoc.skip=true -PskipBundlePlugin (16 tests)
  • ./mvnw -pl quickfixj-base test -Dmaven.javadoc.skip=true -PskipBundlePlugin (170 tests)

Fixes #1283

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.58%. Comparing base (d63552e) to head (29042a4).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1309      +/-   ##
============================================
+ Coverage     70.38%   70.58%   +0.20%     
- Complexity     2247     2254       +7     
============================================
  Files           159      159              
  Lines          9065     9061       -4     
  Branches       1192     1189       -3     
============================================
+ Hits           6380     6396      +16     
+ Misses         2220     2197      -23     
- Partials        465      468       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kangdaeun1022
kangdaeun1022 marked this pull request as ready for review August 25, 2026 17:43
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.

Code duplication - checksum calculation

1 participant