Skip to content

Allocate Snappy stream buffers from the effective block size - #769

Open
curforever wants to merge 1 commit into
xerial:mainfrom
curforever:fix/normalized-block-buffers
Open

curforever wants to merge 1 commit into
xerial:mainfrom
curforever:fix/normalized-block-buffers

Conversation

@curforever

Copy link
Copy Markdown

Fixes #173.

SnappyOutputStream clamps its effective block size to MIN_BLOCK_SIZE, but allocates both buffers using the original constructor argument. For small requested sizes, bulk and primitive-array writes use the larger effective size and can exceed the allocated input buffer; negative values fail allocation despite the existing clamp.

Size both buffers from this.blockSize, preserving the existing minimum normalization, upper limit and stream format. No native code or build configuration changes.

Validation on Windows x86_64 / Microsoft OpenJDK21 / upstream sbt2.0.10, keeping the original --release8 target:

  • Same21 parameterized regression cases:10 failures/errors before, all21 pass after; bulk and single-byte writes, explicit flush/close, multi-block long-array round trips, and sizes below/at/above the minimum. A capacity assertion protects the unfixed JNI path; a non-caching allocator makes capacity deterministic and isolates pooled state.
  • testFull with temporary set exportJars := false: 166 passing, 1 original/default skipped, zero failures/errors.
  • scalafmtCheckAll, package and JAR integration pass. Integration uses the unchanged upstream SnappyIntegrationTest.java, with Windows classpath separation and an E-local temporary directory.

The original-default Windows test invocation failed before tests because the OSGi plugin could not replace a JAR in use. sbt2 defaults exportJars to true; the test runs use its documented command-line opt-out to compiled class directories. For the class-directory full suite, original main resources were temporarily merged into the class output so the existing isolated-CodeSource loader test could find them. Those exact owned copies were removed before the standalone package, which uses the unchanged defaults and is followed by the actual JAR integration test. The intermediate class/resource isolation failure is retained in the logs; no test was disabled. No skip flags, exclusions or dependency/build-file changes were added. The bundled Windows native library was exercised; other OS/JDK matrix cells and native rebuilds were not run locally. No performance result is claimed.

Prepared with assistance from OpenAI Codex; the validation commands above were run locally.

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.

Very general syntax error in SnappyOutputStream constructor

1 participant