From 1e1aee5c4bed517caa721e325f1be3500dc02ba6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 4 Jan 2025 16:52:25 -0800 Subject: [PATCH] Fix #41: propagate configured `PrettyPrinter` to JsonGenerator (#42) --- .../fasterxml/jackson/jakarta/rs/base/ProviderBase.java | 7 ++++++- release-notes/VERSION-2.x | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/fasterxml/jackson/jakarta/rs/base/ProviderBase.java b/base/src/main/java/com/fasterxml/jackson/jakarta/rs/base/ProviderBase.java index 05415d0..f4a0da3 100644 --- a/base/src/main/java/com/fasterxml/jackson/jakarta/rs/base/ProviderBase.java +++ b/base/src/main/java/com/fasterxml/jackson/jakarta/rs/base/ProviderBase.java @@ -565,7 +565,12 @@ public void writeTo(Object value, Class type, Type genericType, Annotation[] try { // Want indentation? if (writer.isEnabled(SerializationFeature.INDENT_OUTPUT)) { - g.useDefaultPrettyPrinter(); + PrettyPrinter defaultPrettyPrinter = writer.getConfig().getDefaultPrettyPrinter(); + if (defaultPrettyPrinter != null) { + g.setPrettyPrinter(defaultPrettyPrinter); + } else { + g.useDefaultPrettyPrinter(); + } } JavaType rootType = null; diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 036318e..672ab4a 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -15,6 +15,8 @@ Sub-modules: #36: Narrow types to format specific (e.g. CBORMapper) when resolving via JAX-RS Providers (suggested by Kevin W) +#41: Configure `PrettyPrinter` not correctly propagated to underlying + `JsonGenerator` * Woodstox dependency now 7.1.0 2.18.2 (27-Nov-2024)