Skip to content

[feature #268890] Fix JdbcTableInputStream large-file buffer handling and add tests - #15

Merged
ecki merged 2 commits into
ecki:masterfrom
seeburger-ag:local-work
Jul 27, 2026
Merged

ecki merged 2 commits into
ecki:masterfrom
seeburger-ag:local-work

Conversation

@klambert-see

@klambert-see klambert-see commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved JDBC table streaming for files of any size by loading data in manageable chunks.
    • Reading, skipping, and checking available data now work correctly across chunk boundaries.
    • Streams retry safely after temporary data-loading errors.
    • Mark and reset operations now provide clear errors when resetting after moving beyond the marked chunk.
  • Tests

    • Added coverage for large-file reads, skipping, availability checks, retry behavior, and mark/reset boundaries.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 647d4017-17dd-4ee6-b258-3472db8810f0

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9c00c and 7fcc7bb.

📒 Files selected for processing (4)
  • pom.xml
  • vfs2provider-jdbctable/pom.xml
  • vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java
  • vfs2provider-jdbctable/src/test/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStreamTest.java

📝 Walkthrough

Walkthrough

JdbcTableInputStream now reads JDBC-backed files in bounded chunks, including cross-boundary reads, skips, availability, and retry handling. Mark/reset is limited to the current chunk. Mockito test dependencies and boundary-focused tests were added.

Changes

JDBC chunked stream reads

Layer / File(s) Summary
Chunk loading and stream traversal
vfs2provider-jdbctable/src/main/java/.../JdbcTableInputStream.java
Chunk state and reloading support are added, and stream operations traverse successive JDBC chunks while preserving position on load failures.
Boundary tests and Mockito wiring
pom.xml, vfs2provider-jdbctable/pom.xml, vfs2provider-jdbctable/src/test/.../JdbcTableInputStreamTest.java
Mockito is managed at version 4.11.0, and tests cover chunk boundaries, retries, availability, and invalidated marks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JdbcTableInputStream
  participant JdbcTableRowFile
  participant FileContent
  JdbcTableInputStream->>JdbcTableRowFile: Request initial chunk
  JdbcTableRowFile->>FileContent: Read JDBC content
  JdbcTableInputStream->>JdbcTableRowFile: Request next chunk at absolute position
  JdbcTableRowFile->>FileContent: Read subsequent JDBC content
  JdbcTableInputStream-->>JdbcTableInputStream: Update buffer and stream position
Loading
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java (1)

33-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor visibility inconsistency: dataDescription isn't private like chunkLoader.

chunkLoader is private final, but dataDescription (Line 44) has default (package) visibility. Unless package-private access is intentionally needed elsewhere, tighten it for consistency/encapsulation.

🔧 Suggested fix
-    final DataDescription dataDescription;
+    private final DataDescription dataDescription;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java`
around lines 33 - 48, Change the dataDescription field in JdbcTableInputStream
to private final, matching chunkLoader, unless an explicitly required
package-level access use exists.
vfs2provider-jdbctable/src/test/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStreamTest.java (1)

144-171: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Tests only ever exercise a single chunk boundary; the MAX_BUFFER_SIZE cap and error path in loadNextChunk() are not verified.

nextReadData's mock computes len = min(maxLen, fullData.length - desc.pos). Since production loadNextChunk() passes maxLen = min(MAX_BUFFER_SIZE, dataLength - nextPos), and these test files are tiny relative to 50 MB, maxLen always resolves to "all remaining bytes" — so every test after the first (artificially truncated) chunk loads the entire remainder in one shot rather than genuinely chunking further. None of the tests currently exercise: (1) more than one chunk-to-chunk transition, or (2) nextReadData throwing IOException (the "content has changed" path), which is exactly where stale dataDescription.pos state (see the loadNextChunk() comment in JdbcTableInputStream.java) would surface.

Consider adding a test that stubs nextReadData to throw once and asserts stream state/behavior on a subsequent call, and/or exposing a package-private way to shrink the effective chunk size beyond the first chunk for a multi-boundary test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@vfs2provider-jdbctable/src/test/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStreamTest.java`
around lines 144 - 171, Strengthen the JdbcTableInputStream tests around
buildStream and loadNextChunk by forcing nextReadData to honor a small effective
chunk size, so reads traverse multiple chunk boundaries instead of loading the
entire remainder. Add coverage for nextReadData throwing IOException, asserting
the documented stream state and behavior on the subsequent call, including
correct handling of dataDescription.pos. Use a package-private chunk-size
override or equivalent test hook if needed without changing production behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java`:
- Line 215: Update mark/reset handling in JdbcTableInputStream so reset()
detects when the stream has moved to a different chunk since mark(). Record the
marked chunk’s starting dataDescription.pos in mark(), compare it with the
current chunk in reset(), and throw IOException on mismatch; only restore
bufferPos when both positions refer to the same chunk.
- Around line 62-115: Update the chunk-loading flow in loadNextChunk and the
chunkLoader lambda to preserve dataDescription.pos when file.nextReadData fails.
Save the prior position before assigning the requested pos, restore it if the
load throws, and ensure retries compute the next chunk from the unchanged prior
state.

---

Nitpick comments:
In
`@vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java`:
- Around line 33-48: Change the dataDescription field in JdbcTableInputStream to
private final, matching chunkLoader, unless an explicitly required package-level
access use exists.

In
`@vfs2provider-jdbctable/src/test/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStreamTest.java`:
- Around line 144-171: Strengthen the JdbcTableInputStream tests around
buildStream and loadNextChunk by forcing nextReadData to honor a small effective
chunk size, so reads traverse multiple chunk boundaries instead of loading the
entire remainder. Add coverage for nextReadData throwing IOException, asserting
the documented stream state and behavior on the subsequent call, including
correct handling of dataDescription.pos. Use a package-private chunk-size
override or equivalent test hook if needed without changing production behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 86a3c89c-e128-49e1-b2e8-6df9b60a8036

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9c00c and f182c04.

📒 Files selected for processing (4)
  • pom.xml
  • vfs2provider-jdbctable/pom.xml
  • vfs2provider-jdbctable/src/main/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStream.java
  • vfs2provider-jdbctable/src/test/java/com/seeburger/vfs2/provider/jdbctable/JdbcTableInputStreamTest.java

@ecki
ecki merged commit 834d871 into ecki:master Jul 27, 2026
2 checks passed
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.

2 participants