← Back to Pull requests

buffer-api: expose buffer contents as byte arrays #3696

Closed
unknown closed this pull request without merging on Nov 16, 2026 19:23 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 22:26 UTC
Author

Motivation

Getting a buffer's bytes currently requires callers to account for readable
offsets and the underlying storage type. A discoverable API on Buffer
centralizes this conversion without requiring an internal utility dependency.

Modifications

  • Add readable-region and indexed Buffer.toByteArray overloads. They copy by

  • default, preserve reader and writer indices, and validate indexed regions
    against the buffer capacity.
  • Add an explicit optional-copy mode that may reuse an exactly matching backing

  • array and returns a shared array for all zero-length results.
  • Cover empty, heap, direct, sliced, read-only, composite, indexed, bounds, and

  • shared-array cases.
  • Migrate ByteArraySerializer, Jackson deserializers, and Jersey while

  • preserving each caller's existing consumption and zero-copy behavior.
  • Remove the internal BufferUtils, its tests, and its unnecessary

  • dependencies. Restore the unrelated varint test to the PR base version.

    Result

    Applications and internal callers can obtain byte arrays through a consistent
    public Buffer API, with copying as the safe default and explicit backing-array
    reuse when requested.

    Validation: 1,027 tests passed across the ten affected modules; nine tests were
    skipped. Repository compilation, affected-module quality checks, dependency
    analysis, documentation validation, and ./gradlew quality passed.

    Closes #863.

    Diff: 177 lines (+132 / -45) across 2 files Reviewer: idelpivnitskiy Review duration: 32937m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 177 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.310
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3696"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.4% (MEDIUM) · Higher = larger blast radius
    35.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14% · Safe to merge
    14%