JsonDeserializer implements Deserializer<T> { @Override public T deserialize(byte[] bytes) { try { return mapper.readValue(bytes, clazz); } catch (IOException e) { logger.warn("Unable to deserialize Object from byte array returning null", e); return null; } } JsonDeserializer(Class<T> clazz); @Override T deserialize(byte[] bytes); @Override void close();  }
@Test public void deserialize() { MyPojo pojo; try (JsonDeserializer<MyPojo> deserializer = new JsonDeserializer<>(MyPojo.class)) { pojo = deserializer.deserialize(POJO_STRING.getBytes()); } assertEquals(POJO, pojo); }