Tidy docs image layout, tighten ISO-8859-1 usage, add ByteBuffer helper, and mark legacy Bytes APIs as deprecated - #716
Open
peter-lawrey wants to merge 43 commits into
Open
Tidy docs image layout, tighten ISO-8859-1 usage, add ByteBuffer helper, and mark legacy Bytes APIs as deprecated#716peter-lawrey wants to merge 43 commits into
peter-lawrey wants to merge 43 commits into
Conversation
…o comments, variable declarations, and encoding handling
…larity and consistency
…s for ElasticBenchmarkRunner, ElasticByteBufferJmh, ElasticDirectJmh, and related classes to clarify their purpose and usage.
…improved code clarity
# Conflicts: # GEMINI.md # src/main/java/net/openhft/chronicle/bytes/BytesStore.java # src/test/java/net/openhft/chronicle/bytes/NativeBytesStoreTest.java # src/test/java/net/openhft/chronicle/bytes/algo/OptimisedBytesStoreHashTest.java
…y and consistency
Rolled versions to 2026.0
tgd
removed their request for review
April 28, 2026 09:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Functional changes
Docs image relocation
Move documentation images from
docs/images/**tosrc/main/docs/images/**so they live alongside the AsciiDoc sources and can be packaged/linked consistently:Figure1.png,bytes2.jpg, IntelliJ data-view screenshots, andsource/Figure1.svg.All paths in
README.adocand other docs now expect the newsrc/main/docs/images/location (consistent with other modules).More robust ByteBuffer handling across JDK versions
Introduce
net.openhft.chronicle.bytes.internal.BufferUtilwith helpers:setPosition(ByteBuffer, int),setLimit(ByteBuffer, int),clear(ByteBuffer),flip(ByteBuffer).Replace direct
buffer.position()/limit()/clear()calls in core classes (NativeBytes,VanillaBytes,UncheckedNativeBytes, tests) with these helpers to keep the explicit(Buffer)cast in one place and avoid JDK-8 vs JDK-9+ bytecode quirks.Consistent ISO-8859-1 usage
String.getBytes()andnew String(byte[])with explicitISO_8859_1in core code (Bytes,BytesStore,NativeBytesStore,BytesUtil) and tests.Safer and clearer string/byte parsing behaviour
ByteStringParser.parse8bit(Appendable, StopCharTester):StringBuilderandBytesdirectly, but now also supports anyAppendableby buffering into aStringBuilderand copying via a safe helper (appendTo).ByteStringParser.parse8bit(Appendable, StopCharsTester)givenAppendablebehaves similarly, falling back toStringBuilderfor non-optimised appendables.These paths now throw
IORuntimeExceptionif a foreignAppendablehas anIOExceptionduring append, rather than silently ignoring it.Content-equals and vectorised mismatch behaviour tightened
BytesInternal.java11ContentEqualUsingVectorizedMismatch:UnsupportedOperationExceptionif either side is not backed by aHeapBytesStore, instead of returningnulland silently falling back in the caller.UnsupportedOperationExceptionafter logging, rather than returningnull.This makes failures around the Java-11
Arrays.mismatchpath explicit and easier to diagnose; tests have been updated accordingly.Mapped file and bytes boundary behaviour more thoroughly exercised
Add tests to verify:
MappedBytes.zeroOut()clears bytes correctly when a custom page size is used and the range crosses page boundaries.MappedFile/MappedBytesStore.safeLimit()andinside(long)remain coherent when the mapping page size differs from the OS default (new “page matrix” tests).No changes to the production
MappedFileAPI, but we now assert correctness under more configurations.Guarded / unchecked behaviour and overflow semantics
UncheckedBytesBehaviourTestnow asserts unchecked writes can advance past ‘writeLimit’ without failing, while the checked view remains constrained.NativeBytesOverflowTestandDecoratedBufferOverflowExceptionTestconfirm:DecoratedBufferOverflowExceptionbut keepgetCause()null.Bounds/loop correctness and minor behavioural fixes
Several small correctness improvements:
Bytes.indexOf(Bytes)andBytes.indexOf(BytesStore, int)restructure internal variables to avoid subtle order-of-use bugs; the external contract is unchanged.BytesUtil.combineDoubleNewlinenow has explicitdefaulthandling and earlyreturns for non-matching cases, making the switch behaviour easier to reason about.BinaryIntArrayReference.bindValueAtandBinaryLongArrayReference.bindValueAtnow validate that the suppliedIntValue/LongValueis the expectedBinary*Referencesubtype and throwIllegalArgumentExceptionotherwise, instead of silently casting.HeapBytesStore.appendAndReturnLengthnow consistently uses the originalwritePositionparameter for bothreverseBytesFromandlengthcalculation, removing a redundant local and making the code easier to audit.Error-handling and warning improvements
PageUtil.parsePageSizenow:DEFAULT_HUGE_PAGE_SIZEas before, but with clearer diagnostics.Numerous tests now assert
histogramand timing counters are actually updated (e.g.MappedUniqueTimeProviderTest,DistributedUniqueTimeProviderTest, jitter tests) instead of just printing metrics.Non-functional changes
API deprecation and clean-up
A large set of rarely used / test-only methods and legacy helpers are now marked
@Deprecatedwith explicit removal targets “to be removed in 2027”, for example:AppendableUtil.append(...)with customAppendable & CharSequence,AppendableUtil.findUtf8Length(byte[]),StandardDecimaliser.toDecimal(...),MaximumPrecisionconstructor).ByteStringParser.parseBoolean(...),parseFloat,parseLongDecimal,parseBigDecimal,lastNumberHadDigits(), various UTF-8 helpers and “not atomic” add-and-get methods).Bytes,BytesStore,BytesRingBuffer,BytesIn,BytesOut,BytesContext,MappedFile,MappedBytes,DistributedUniqueTimeProvider,MappedUniqueTimeProvider, refs, compression, interning, histogram, and unsafe helpers.StreamingInputStream/StreamingOutputStreamdefault constructors andinit(...)methods.Call sites in tests are updated and annotated with
@SuppressWarnings("deprecation")where appropriate so the current build stays clean while giving downstream users time to move away from these APIs.Javadoc and documentation polish
Improve class-level Javadoc on core types (
Bytes,BytesStore,BytesIn,BytesOut,StreamingDataInput,RandomDataInput,RandomDataOutput,BytesRingBuffer,OffsetFormat,Invocation,NativeBytesStore,SingleMappedFile,ReentrantFileLock, etc.) to:releaseLast().architecture-overview.adoc,memory-management.adoc,domestic-overview.adoc).Add/extend
package-info.javafor:bytes.internal,bytes.algo,bytes.pool,bytes.ref,bytes.render,bytes.util,bytes.domestic, and the newbytes.internal.migration.Tests and examples (
readmetests) are tweaked to useISO_8859_1where strings are converted, aligning with the project’s charset policy.Static analysis, determinism, and test robustness
new Random()andSecureRandominvocations with seeded instances (new Random(1L)or similar) to make tests deterministic and friendlier to static analysis and CI.BytesUtilTest’s trivially-copyable structs) to keep SpotBugs and other tools satisfied that these code paths are exercised.ByteStringReaderWriterTest,BytesReleaseInvariantNonPerformantMethodsTest,ByteStoreTest,MappedFileTest,CanonicalPathUtilTest, etc.) to avoid resource warnings and make intent clearer.Minor style and clarity improvements
finalfields (for exampleSIZEin JLBH and jitter tests) and reformat loops andswitchstatements for readability.isDirectMemoryReturnsExpectedValue), and convert some JUnit 4 assertions to JUnit 5 where those tests already use JUnit 5 APIs.PropertyReplacer.convertStreamToString), now that all supported environments can use the main APIs.Overall, this PR is primarily non-functional: it relocates documentation assets, tightens charset usage, introduces a central
BufferUtilfor JDK compatibility, and marks a broad set of legacy APIs as deprecated while adding tests and documentation to support long-term clean-up. The functional changes are small and targeted toward robustness (better exception signalling in vectorised equality, clearer align/zeroOut handling, safer parsing for genericAppendables, and well-defined overflow semantics).