From 72e6ddd919bbcd330a26999559f00cb4036364f3 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Fri, 22 Aug 2025 11:02:44 +0200 Subject: [PATCH] Improve null-safety of module/spring-boot-rsocket See gh-46926 --- .../RSocketPortInfoApplicationContextInitializer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java b/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java index f553db632e6..ad878efd231 100644 --- a/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java +++ b/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java @@ -16,6 +16,7 @@ package org.springframework.boot.rsocket.context; +import java.net.InetSocketAddress; import java.util.HashMap; import java.util.Map; @@ -65,8 +66,9 @@ public class RSocketPortInfoApplicationContextInitializer @Override public void onApplicationEvent(RSocketServerInitializedEvent event) { - if (event.getServer().address() != null) { - setPortProperty(this.applicationContext, event.getServer().address().getPort()); + InetSocketAddress address = event.getServer().address(); + if (address != null) { + setPortProperty(this.applicationContext, address.getPort()); } }