From 42e23e54ff99e4e97d9c7c31256a4378a7533ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A5le=20Undheim?= Date: Sat, 24 Feb 2018 00:25:34 +0100 Subject: [PATCH] Fix to issue #180 to handle null contentType If the content type is null, the call for .toString on it will cause an NPE. This fixes this issue by wrapping the call in an Option, then mapping toString or falling back to null. getCharSetFromContentType handles null by returning ISO-8859-1 --- .../internal/librarymanagement/ivyint/GigahorseUrlHandler.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala index b8da74aab..e83f55177 100644 --- a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala +++ b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala @@ -51,7 +51,7 @@ class GigahorseUrlHandler extends AbstractURLHandler { if (checkStatusCode(url, response)) { val bodyCharset = - BasicURLHandler.getCharSetFromContentType(response.body().contentType().toString) + BasicURLHandler.getCharSetFromContentType(Option(response.body().contentType()).map(_.toString).orNull) Some( new SbtUrlInfo(true, response.body().contentLength(),