Skip to content

Commit

Permalink
Protect from ArrayIndexOutOfBoundsException exception when extracting…
Browse files Browse the repository at this point in the history
… values for user agent. (ClickHouse#360)
  • Loading branch information
mzitnik authored Oct 28, 2024
1 parent 979f6b0 commit 35088ca
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ class NodeClient(val nodeSpec: NodeSpec) extends AutoCloseable with Logging {
private lazy val userAgent = {
val title = getClass.getPackage.getImplementationTitle
val version = getClass.getPackage.getImplementationVersion
if (version != null) {
if (version != null && title != null) {
val versions = version.split("_")
val sparkVersion = versions(0)
val scalaVersion = versions(1)
val connectorVersion = versions(2)
s"${title}/${connectorVersion} (fv:spark/${sparkVersion}, lv:scala/${scalaVersion})"
if (versions.length < 3) {
"Spark-ClickHouse-Connector"
} else {
val sparkVersion = versions(0)
val scalaVersion = versions(1)
val connectorVersion = versions(2)
s"${title}/${connectorVersion} (fv:spark/${sparkVersion}, lv:scala/${scalaVersion})"
}
} else {
"Spark-ClickHouse-Connector"
}
Expand Down

0 comments on commit 35088ca

Please sign in to comment.