Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Java: Add handling of unexpected end of data stream [ISSUE#80](https://github.com/openstreetmap/OSM-binary/issues/80)

## Release notes for 1.6.0 (2024-12-10)

- Java: Update to latest protoc and protobuf runtime versions [#84](https://github.com/openstreetmap/OSM-binary/pull/84)
Expand Down
Binary file added resources/broken7000bytes.pbf
Binary file not shown.
8 changes: 4 additions & 4 deletions src.java/crosby/binary/file/BlockInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ License, or (at your option) any later version.
package crosby.binary.file;

import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

Expand All @@ -29,13 +28,14 @@ public BlockInputStream(InputStream input, BlockReaderAdapter adaptor) {
this.adaptor = adaptor;
}

public void process() throws IOException {
public void process() throws Exception {
try {
while (true) {
while (input.available() > 0) {
FileBlock.process(input, adaptor);
}
} catch (EOFException e) {
adaptor.complete();
} catch (Exception e) {
adaptor.failure(e);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src.java/crosby/binary/file/BlockReaderAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface BlockReaderAdapter {

/** Called when the file is fully read. */
void complete();

void failure(Exception e) throws Exception;
}
Loading