Skip to content

Commit

Permalink
resolving a comment about failing fast in the simulator
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Atanasov <[email protected]>
  • Loading branch information
ata-nas committed Oct 28, 2024
1 parent 2363021 commit 7a758e7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import javax.inject.Inject;

/** A block stream manager that reads blocks from files in a directory. */
Expand Down Expand Up @@ -90,10 +91,14 @@ public Block getNextBlock() throws IOException, BlockSimulatorParsingException {
final byte[] blockBytes =
FileUtilities.readFileBytesUnsafe(localBlockStreamPath, RECORD_EXTENSION, GZ_EXTENSION);

if (Objects.isNull(blockBytes)) {
throw new NullPointerException(
"Unable to read block file [%s]! Most likely not found with the extensions '%s' or '%s'"
.formatted(localBlockStreamPath, RECORD_EXTENSION, GZ_EXTENSION));
}

LOGGER.log(INFO, "Loading block: " + localBlockStreamPath.getFileName());

// todo blockBytes could be null, should we hande in some way or we need this method to
// fail here?
final Block block = Block.PROTOBUF.parse(Bytes.wrap(blockBytes));
LOGGER.log(INFO, "block loaded with items size= " + block.items().size());
return block;
Expand Down

0 comments on commit 7a758e7

Please sign in to comment.