Skip to content

Commit

Permalink
Merge pull request #554 from akkinoc/fix/96
Browse files Browse the repository at this point in the history
Suppresses NullPointerException that occurs when the server name is missing
  • Loading branch information
akkinoc authored Jan 25, 2025
2 parents d5eb93c + b63c6c6 commit 163e614
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LogbackAccessEvent(private var source: LogbackAccessEventSource) : IAccess
}

override fun getServerName(): String {
return source.serverName
return source.serverName ?: NA
}

override fun getLocalPort(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class LogbackAccessEventSource {
/**
* The value of [IAccessEvent.getServerName].
*/
abstract val serverName: String
abstract val serverName: String?

/**
* The value of [IAccessEvent.getLocalPort].
Expand Down Expand Up @@ -185,7 +185,7 @@ abstract class LogbackAccessEventSource {

override val threadName: String = source.threadName

override val serverName: String = source.serverName
override val serverName: String? = source.serverName

override val localPort: Int = source.localPort

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LogbackAccessJettyEventSource(

override val threadName: String = currentThread().name

override val serverName: String by lazy(LazyThreadSafetyMode.NONE) {
override val serverName: String? by lazy(LazyThreadSafetyMode.NONE) {
Request.getServerName(rawRequest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LogbackAccessTomcatEventSource(

override val threadName: String = currentThread().name

override val serverName: String by lazy(LazyThreadSafetyMode.NONE) {
override val serverName: String? by lazy(LazyThreadSafetyMode.NONE) {
request.getAccessLogAttribute(SERVER_NAME_ATTRIBUTE) ?: request.serverName
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LogbackAccessUndertowEventSource(

override val threadName: String = currentThread().name

override val serverName: String by lazy(LazyThreadSafetyMode.NONE) {
override val serverName: String? by lazy(LazyThreadSafetyMode.NONE) {
exchange.hostName
}

Expand Down

0 comments on commit 163e614

Please sign in to comment.