Skip to content

Commit 07428e9

Browse files
committed
Fix possible null
1 parent 2205e6e commit 07428e9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

app/src/main/java/net/xcreen/restsms/server/SMSWelcomeServlet.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.xcreen.restsms.server
22

33
import java.io.IOException
4-
import java.net.InetAddress
54
import java.net.NetworkInterface
65
import java.util.*
76
import javax.servlet.http.HttpServlet
@@ -25,12 +24,12 @@ class SMSWelcomeServlet(private val serverLogging: ServerLogging) : HttpServlet(
2524
response.writer.println("Server IP Address: $localIpAddress")
2625
}
2726

28-
private fun getLocalIpAddress(): String {
27+
private fun getLocalIpAddress(): String? {
2928
val networkInterfaces = NetworkInterface.getNetworkInterfaces()
3029
for (interfaceElement in Collections.list(networkInterfaces)) {
3130
val inetAddresses = interfaceElement.inetAddresses
3231
for (inetAddress in Collections.list(inetAddresses)) {
33-
if (!inetAddress.isLoopbackAddress && inetAddress.hostAddress.indexOf(':') == -1) {
32+
if (!inetAddress.isLoopbackAddress && inetAddress?.hostAddress?.indexOf(':') == -1) {
3433
return inetAddress.hostAddress
3534
}
3635
}

0 commit comments

Comments
 (0)