|
@@ -19,7 +19,7 @@ package org.apache.hadoop.crypto.key.kms.server;
|
|
|
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
|
-
|
|
|
+import org.codehaus.jackson.map.ObjectWriter;
|
|
|
import javax.ws.rs.Produces;
|
|
|
import javax.ws.rs.WebApplicationException;
|
|
|
import javax.ws.rs.core.MediaType;
|
|
@@ -44,6 +44,8 @@ import java.util.Map;
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
@InterfaceAudience.Private
|
|
|
public class KMSJSONWriter implements MessageBodyWriter<Object> {
|
|
|
+ private static final ObjectWriter WRITER =
|
|
|
+ new ObjectMapper().writerWithDefaultPrettyPrinter();
|
|
|
|
|
|
@Override
|
|
|
public boolean isWriteable(Class<?> aClass, Type type,
|
|
@@ -65,8 +67,7 @@ public class KMSJSONWriter implements MessageBodyWriter<Object> {
|
|
|
OutputStream outputStream) throws IOException, WebApplicationException {
|
|
|
Writer writer = new OutputStreamWriter(outputStream, Charset
|
|
|
.forName("UTF-8"));
|
|
|
- ObjectMapper jsonMapper = new ObjectMapper();
|
|
|
- jsonMapper.writerWithDefaultPrettyPrinter().writeValue(writer, obj);
|
|
|
+ WRITER.writeValue(writer, obj);
|
|
|
}
|
|
|
|
|
|
}
|