### Question:
OAuthJSONProvider implements MessageBodyWriter<Object>,
    MessageBodyReader<Object> { public Map<String, String> readJSONResponse(InputStream is) throws IOException { String str = IOUtils.readStringFromStream(is).trim(); if (str.length() == 0) { return Collections.emptyMap(); } Map<String, Object> response = new JsonMapObjectReaderWriter().fromJson(str); Map<String, String> forcedStringResponse = new HashMap<>(response.size()); for (Map.Entry<String, Object> entry : response.entrySet()) { forcedStringResponse.put(entry.getKey(), entry.getValue().toString()); } return forcedStringResponse; }  long getSize(Object obj, Class<?> clt, Type t, Annotation[] anns, MediaType mt); boolean isWriteable(Class<?> cls, Type t, Annotation[] anns, MediaType mt); void writeTo(Object obj, Class<?> cls, Type t, Annotation[] anns, MediaType mt,
                        MultivaluedMap<String, Object> headers, OutputStream os); boolean isReadable(Class<?> cls, Type t, Annotation[] anns, MediaType mt); Object readFrom(Class<Object> cls, Type t, Annotation[] anns,
                           MediaType mt, MultivaluedMap<String, String> headers, InputStream is); Map<String, String> readJSONResponse(InputStream is);  }### Answer:
@Test public void testReadException() throws IOException { String response = "{" + "\"error\":\"invalid_client\"," + "\"error_description\":\"Client authentication failed\"" + "}"; OAuthJSONProvider provider = new OAuthJSONProvider(); Map<String, String> responseMap = provider.readJSONResponse(new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8))); assertEquals(responseMap.size(), 2); assertEquals("invalid_client", responseMap.get("error")); assertEquals("Client authentication failed", responseMap.get("error_description")); }
@Test public void testReadExceptionWithCommaInMessage() throws IOException { String response = "{" + "\"error\":\"invalid_client\"," + "\"error_description\":\"Client authentication failed, due to xyz\"" + "}"; OAuthJSONProvider provider = new OAuthJSONProvider(); Map<String, String> responseMap = provider.readJSONResponse(new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8))); assertEquals(responseMap.size(), 2); assertEquals("invalid_client", responseMap.get("error")); assertEquals("Client authentication failed, due to xyz", responseMap.get("error_description")); }