From e3f612e6544a587e0a0a515134acf2e37716c371 Mon Sep 17 00:00:00 2001 From: badrinathpatchikolla Date: Wed, 30 Nov 2022 02:41:01 +0530 Subject: [PATCH] Fixed r.statusCode to Handle NUll --- README.md | 16 ++++++++-------- .../the/ainur/almaren/http/HTTPConnector.scala | 10 ++++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 38619f3..63b71e4 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ To add HTTP connector dependency to your sbt build: ``` -libraryDependencies += "com.github.music-of-the-ainur" %% "http-almaren" % "1.2.5-2.4" +libraryDependencies += "com.github.music-of-the-ainur" %% "http-almaren" % "1.2.6-2.4" ``` To run in spark-shell: ``` -spark-shell --master "local[*]" --packages "com.github.music-of-the-ainur:almaren-framework_2.11:0.9.8-2.4,com.github.music-of-the-ainur:http-almaren_2.11:1.2.5-2.4" +spark-shell --master "local[*]" --packages "com.github.music-of-the-ainur:almaren-framework_2.11:0.9.8-2.4,com.github.music-of-the-ainur:http-almaren_2.11:1.2.6-2.4" ``` ## Table of Contents @@ -41,12 +41,12 @@ repository. | version | Connector Artifact | |----------------------------|-------------------------------------------------------------| -| Spark 3.3.x and scala 2.13 | `com.github.music-of-the-ainur:http-almaren_2.13:1.2.5-3.3` | -| Spark 3.3.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.5-3.3` | -| Spark 3.2.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.5-3.2` | -| Spark 3.1.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.5-3.1` | -| Spark 2.4.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.5-2.4` | -| Spark 2.4.x and scala 2.11 | `com.github.music-of-the-ainur:http-almaren_2.11:1.2.5-2.4` | +| Spark 3.3.x and scala 2.13 | `com.github.music-of-the-ainur:http-almaren_2.13:1.2.6-3.3` | +| Spark 3.3.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.6-3.3` | +| Spark 3.2.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.6-3.2` | +| Spark 3.1.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.6-3.1` | +| Spark 2.4.x and scala 2.12 | `com.github.music-of-the-ainur:http-almaren_2.12:1.2.6-2.4` | +| Spark 2.4.x and scala 2.11 | `com.github.music-of-the-ainur:http-almaren_2.11:1.2.6-2.4` | ## Methods diff --git a/src/main/scala/com/github/music/of/the/ainur/almaren/http/HTTPConnector.scala b/src/main/scala/com/github/music/of/the/ainur/almaren/http/HTTPConnector.scala index 1fdcc4d..0c746a0 100644 --- a/src/main/scala/com/github/music/of/the/ainur/almaren/http/HTTPConnector.scala +++ b/src/main/scala/com/github/music/of/the/ainur/almaren/http/HTTPConnector.scala @@ -83,7 +83,10 @@ private[almaren] case class HTTP( Some(r.text()), r.headers, Some(r.statusCode), - Some(r.statusMessage), + r.statusMessage match { + case null => None + case _ => Some(r.statusMessage) + }, `__ELAPSED_TIME__` = elapsedTime, `__URL__` = url) case Failure(f) => { @@ -124,7 +127,10 @@ private[almaren] case class HTTPBatch( Some(r.text()), r.headers, Some(r.statusCode), - Some(r.statusMessage), + r.statusMessage match { + case null => None + case _ => Some(r.statusMessage) + }, `__ELAPSED_TIME__` = System.currentTimeMillis() - startTime, `__URL__` = url, `__DATA__` = data