Skip to content

5.10.2: NPE in batch multi-sheet processing — parallel task lambda returns null, unboxed as Boolean in reachBookStep #960

Description

@recrack

Summary

Since 5.10.x, batch-mode transcription of any multi-sheet book fails with an NPE when sheet-parallel processing is enabled (omr.OmrExecutors.useParallelism default). Single-sheet books are unaffected.

WARN  Book 2073 | Error in performing PAGE
java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "java.util.concurrent.Future.get()" is null
	at org.audiveris.omr.sheet.Book.reachBookStep(Book.java:1981)
	at org.audiveris.omr.sheet.Book.transcribe(Book.java:2626)
	at org.audiveris.omr.sheet.Book.export(Book.java:593)
	at org.audiveris.omr.CLI$ProcessingTask.processBook(CLI.java:927)

Root cause

In Book.reachBookStep (parallel branch), the Callable<Boolean> lambda returns null:

tasks.add( () -> {
    LogUtil.start(stub);
    try {
        stub.reachStep(maxStep, force);
        if (OMR.gui == null) {
            stub.swapSheet();
        }
        return null;          // <-- here
    } finally { ... }
});

while the consuming loop unboxes the result:

for (Future<Boolean> future : futures) {
    if (!future.get()) {      // NPE: null.booleanValue()
        someFailure = true;
    }
}

In 5.8.1 the lambda returned true, so this is a regression. Still present on current master (ec7350e).

Reproduction

Any book with 2+ sheets, batch mode:

Audiveris -batch -transcribe -export some-multipage.pdf

→ every sheet transcribes fine, then Error in performing PAGE + Could not export since transcription did not complete successfully. With useParallelism=false the same book succeeds.

Fix + measured result

Restoring the 5.8.1 behavior (one line, return null;return true;) fixes it. With that patch applied on top of 5.10.2 we ran our regression corpus (piano scores, OpenScore Lieder ground truth) — 5.10.2 then works and is a clear improvement over 5.8.1:

corpus item 5.8.1 pitch/note F1 5.10.2+fix pitch/note F1 time
lieder-volkslied (2 pages) 0.8174 / 0.7565 0.9652 / 0.8957 16.4s → 14.2s
lieder-an-laura 0.99 / 0.92 0.99 / 0.92 18.7s → 13.0s
lieder-der-winter 1.0 / 0.9913 1.0 / 0.9913 13.5s → 12.6s
4-page book (no ground truth) works, no NPE 34.4s → 24.5s

Happy to open a PR with the one-line fix if useful.

Environment: OpenJDK 25, macOS 14 (also reproduced in Debian bookworm container).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions