diff --git a/http-client/src/test/java/io/airlift/http/client/TestFullJsonResponseHandler.java b/http-client/src/test/java/io/airlift/http/client/TestFullJsonResponseHandler.java index 252d8592f0..b781c86756 100644 --- a/http-client/src/test/java/io/airlift/http/client/TestFullJsonResponseHandler.java +++ b/http-client/src/test/java/io/airlift/http/client/TestFullJsonResponseHandler.java @@ -60,7 +60,7 @@ public void testInvalidJson() assertFalse(response.hasValue()); assertEquals(response.getException().getMessage(), format("Unable to create %s from JSON response:\n[%s]", User.class, json)); assertTrue(response.getException().getCause() instanceof IllegalArgumentException); - assertEquals(response.getException().getCause().getMessage(), "Invalid json bytes for [simple type, class io.airlift.http.client.TestFullJsonResponseHandler$User]"); + assertEquals(response.getException().getCause().getMessage(), "Invalid JSON bytes for [simple type, class io.airlift.http.client.TestFullJsonResponseHandler$User]"); assertEquals(response.getJsonBytes(), json.getBytes(UTF_8)); assertEquals(response.getJson(), json); diff --git a/http-client/src/test/java/io/airlift/http/client/TestJsonResponseHandler.java b/http-client/src/test/java/io/airlift/http/client/TestJsonResponseHandler.java index 0b00e7b35c..cef28705ce 100644 --- a/http-client/src/test/java/io/airlift/http/client/TestJsonResponseHandler.java +++ b/http-client/src/test/java/io/airlift/http/client/TestJsonResponseHandler.java @@ -42,7 +42,7 @@ public void testInvalidJson() catch (IllegalArgumentException e) { assertEquals(e.getMessage(), format("Unable to create %s from JSON response:\n[%s]", User.class, json)); assertTrue(e.getCause() instanceof IllegalArgumentException); - assertEquals(e.getCause().getMessage(), "Invalid json bytes for [simple type, class io.airlift.http.client.TestFullJsonResponseHandler$User]"); + assertEquals(e.getCause().getMessage(), "Invalid JSON bytes for [simple type, class io.airlift.http.client.TestFullJsonResponseHandler$User]"); } } diff --git a/json/src/main/java/io/airlift/json/JsonCodec.java b/json/src/main/java/io/airlift/json/JsonCodec.java index 274b3005e4..fa262b859e 100644 --- a/json/src/main/java/io/airlift/json/JsonCodec.java +++ b/json/src/main/java/io/airlift/json/JsonCodec.java @@ -32,6 +32,7 @@ import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT; import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; public class JsonCodec { @@ -138,7 +139,7 @@ public T fromJson(String json) return mapper.readValue(json, javaType); } catch (IOException e) { - throw new IllegalArgumentException(String.format("Invalid json string for %s", javaType), e); + throw new IllegalArgumentException(format("Invalid JSON string for %s", javaType), e); } } @@ -156,7 +157,7 @@ public String toJson(T instance) return mapper.writeValueAsString(instance); } catch (IOException e) { - throw new IllegalArgumentException(String.format("%s could not be converted to json", instance.getClass().getName()), e); + throw new IllegalArgumentException(format("%s could not be converted to JSON", instance.getClass().getName()), e); } } @@ -179,7 +180,7 @@ public Optional toJsonWithLengthLimit(T instance, int lengthLimit) return Optional.empty(); } catch (IOException e) { - throw new IllegalArgumentException(String.format("%s could not be converted to json", instance.getClass().getName()), e); + throw new IllegalArgumentException(format("%s could not be converted to JSON", instance.getClass().getName()), e); } } @@ -197,7 +198,7 @@ public T fromJson(byte[] json) return mapper.readValue(json, javaType); } catch (IOException e) { - throw new IllegalArgumentException(String.format("Invalid json bytes for %s", javaType), e); + throw new IllegalArgumentException(format("Invalid JSON bytes for %s", javaType), e); } } @@ -215,7 +216,7 @@ public byte[] toJsonBytes(T instance) return mapper.writeValueAsBytes(instance); } catch (IOException e) { - throw new IllegalArgumentException(String.format("%s could not be converted to json", instance.getClass().getName()), e); + throw new IllegalArgumentException(format("%s could not be converted to JSON", instance.getClass().getName()), e); } }