Skip to content

Commit

Permalink
Add nonnull characteristic to mirror BufferedReader original logic
Browse files Browse the repository at this point in the history
  • Loading branch information
newtork committed Sep 5, 2024
1 parent f6f122d commit 7aad621
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.sap.ai.sdk.foundationmodels.openai;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Spliterator.NONNULL;
import static java.util.Spliterator.ORDERED;

import io.vavr.control.Try;
import java.io.BufferedReader;
Expand All @@ -10,7 +12,6 @@
import java.io.UncheckedIOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
Expand Down Expand Up @@ -98,7 +99,7 @@ static Stream<String> streamLines(@Nullable final HttpEntity entity)
.onFailure(e -> log.error("Could not close HTTP input stream", e));

final var iterator = new HandledIterator<>(reader::readLine, closeHandler);
final var spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED);
final var spliterator = Spliterators.spliteratorUnknownSize(iterator, ORDERED | NONNULL);
return StreamSupport.stream(spliterator, false).onClose(closeHandler::close);
}
}

0 comments on commit 7aad621

Please sign in to comment.