Skip to content

Commit 567fdf0

Browse files
tilgalascopybara-github
authored andcommitted
fix: fix null handling in runAsyncImpl
PiperOrigin-RevId: 884472852
1 parent 7ebeb07 commit 567fdf0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

core/src/main/java/com/google/adk/runner/Runner.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ protected Flowable<Event> runAsyncImpl(
458458
Content newMessage,
459459
RunConfig runConfig,
460460
@Nullable Map<String, Object> stateDelta) {
461+
Preconditions.checkNotNull(session, "session cannot be null");
462+
Preconditions.checkNotNull(newMessage, "newMessage cannot be null");
463+
Preconditions.checkNotNull(runConfig, "runConfig cannot be null");
461464
return Flowable.defer(
462465
() -> {
463466
BaseAgent rootAgent = this.agent;
@@ -476,19 +479,14 @@ protected Flowable<Event> runAsyncImpl(
476479
.defaultIfEmpty(newMessage)
477480
.flatMap(
478481
content ->
479-
(content != null)
480-
? appendNewMessageToSession(
481-
session,
482-
content,
483-
initialContext,
484-
runConfig.saveInputBlobsAsArtifacts(),
485-
stateDelta)
486-
: Single.just(null))
482+
appendNewMessageToSession(
483+
session,
484+
content,
485+
initialContext,
486+
runConfig.saveInputBlobsAsArtifacts(),
487+
stateDelta))
487488
.flatMapPublisher(
488489
event -> {
489-
if (event == null) {
490-
return Flowable.empty();
491-
}
492490
// Get the updated session after the message and state delta are
493491
// applied
494492
return this.sessionService

0 commit comments

Comments
 (0)