Skip to content

[Bug] LanceScanner/AsyncScanner wraps IOException as bare RuntimeException #7611

Description

@jiangxt2

Version

main branch

Describe what's wrong

LanceScanner.scanBatches() catches IOException from the native openStream() method and wraps it as a bare RuntimeException (line 144). The same pattern exists in AsyncScanner at 4 locations (lines 140, 144, 151, 169).

Callers cannot distinguish IO errors (file not found, permission denied, corrupted data) from programming errors (NPE, etc.) without inspecting the cause chain.

The Arrow Scanner interface's scanBatches() does not declare throws IOException, so a checked exception is not feasible. A typed unchecked exception is preferable to bare RuntimeException.

Evidence of prior intent

FileReaderWriterTest.java already references LanceException in 3 separate fail messages (lines 122, 257, 263), e.g. fail("Expected LanceException to be thrown"). This indicates the community intended to use a custom exception class, but it was never introduced.

Note: those 3 test sites cover LanceFileReader, not LanceScanner. The file reader/writer path is out of scope for this fix and should be addressed in a follow-up.

How to reproduce

  1. Call scanner.scanBatches() on a dataset path that doesn't exist or has permission issues
  2. The native layer throws IOException
  3. The caller receives RuntimeException with no way to catch IO-specific errors

Proposed fix

Introduce LanceException extends RuntimeException as a unified unchecked exception for Lance IO/operation errors:

File Change
java/src/main/java/org/lance/LanceException.java New: extends RuntimeException, constructors (String, Throwable) and (String)
java/src/main/java/org/lance/ipc/LanceScanner.java:144 RuntimeException -> LanceException
java/src/main/java/org/lance/ipc/AsyncScanner.java:140,144,151,169 RuntimeException -> LanceException

Out of scope (follow-up): LanceFileReader / LanceFileWriter IO paths and the 3 FileReaderWriterTest catch blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions