From 94e3266ff4b11bb1c4595df69ad8648a5fb01ea0 Mon Sep 17 00:00:00 2001 From: Ryan Bergman Date: Mon, 23 May 2022 14:35:43 -0500 Subject: [PATCH] update jacoco and kill silly npe --- pom.xml | 2 +- unirest/src/main/java/kong/unirest/json/JSONObject.java | 2 +- unirest/src/test/java/kong/unirest/json/JSONObjectTest.java | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d68de1c2b..5ccd58478 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.8 default-prepare-agent diff --git a/unirest/src/main/java/kong/unirest/json/JSONObject.java b/unirest/src/main/java/kong/unirest/json/JSONObject.java index ca31c0bec..34d3794fd 100644 --- a/unirest/src/main/java/kong/unirest/json/JSONObject.java +++ b/unirest/src/main/java/kong/unirest/json/JSONObject.java @@ -113,7 +113,7 @@ public static Writer quote(String s, Writer writer) throws IOException { * @return a object */ public static Object stringToValue(String str) { - if(str.contentEquals("null")){ + if(str == null || str.contentEquals("null")){ return NULL; } else if (str.equalsIgnoreCase("true")){ return true; diff --git a/unirest/src/test/java/kong/unirest/json/JSONObjectTest.java b/unirest/src/test/java/kong/unirest/json/JSONObjectTest.java index 4cb000b87..05ef3ffda 100644 --- a/unirest/src/test/java/kong/unirest/json/JSONObjectTest.java +++ b/unirest/src/test/java/kong/unirest/json/JSONObjectTest.java @@ -552,8 +552,6 @@ void stringToValue() { assertEquals(42, JSONObject.stringToValue("42")); assertEquals(45.25, JSONObject.stringToValue("45.25")); assertEquals(-45.25, JSONObject.stringToValue("-45.25")); - NullPointerException ex = assertThrows(NullPointerException.class, () -> JSONObject.stringToValue(null)); - assertEquals(null, ex.getMessage()); } @Test