Skip to content

Commit dcf4d0a

Browse files
committed
Include suggestions on what to customize when migrating to own FormatMappers
1 parent 52c39d3 commit dcf4d0a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BuiltinFormatMapperBehaviour.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ private static String message(String puName, String type, List<String> causes) {
5959
+ " and @PersistenceUnitExtension"
6060
+ (PersistenceUnitUtil.isDefaultPersistenceUnit(puName) ? "" : "(\"%1$s\")")
6161
+ " to address your database serialization/deserialization needs."
62-
+ "\nThe reasons why the check was triggered are: \n\t-"
63-
+ String.join("\n\t-", causes)
62+
+ "\nThe reasons why the check was triggered are: \n\t- "
63+
+ String.join("\n\t- ", causes)
6464
+ "\nSee the migration guide for more details and how to proceed.",
6565
puName, type);
6666
}

extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/JsonFormatterCustomizationCheck.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public List<String> apply(ArcContainer container) {
7575
}
7676
// ObjectMapper was potentially customized
7777
causes.add("Detected '" + handle.getBean().getBeanClass().getName() + "' bean registered. "
78-
+ "It may have customized the ObjectMapper in a way not compatible with the default one.");
78+
+ "It may have customized the ObjectMapper in a way not compatible with the default one. "
79+
+ "Review the customizer and apply customizations you need for the database serialization/deserialization of JSON fields to your custom mapper.");
7980
}
8081
}
8182

@@ -87,15 +88,23 @@ public List<String> apply(ArcContainer container) {
8788
"quarkus.jackson.write-durations-as-timestamps", "true",
8889
"quarkus.jackson.accept-case-insensitive-enums", "false",
8990
"quarkus.jackson.timezone", "UTC");
91+
Map<String, String> actionsToTake = Map.of(
92+
"quarkus.jackson.write-dates-as-timestamps",
93+
"disable the corresponding serialization feature, i.e. 'mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)'",
94+
"quarkus.jackson.write-durations-as-timestamps",
95+
"disable the corresponding serialization feature, i.e. 'mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)'",
96+
"quarkus.jackson.accept-case-insensitive-enums",
97+
"enable the corresponding mapper feature, i.e. 'mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)'",
98+
"quarkus.jackson.timezone", "configure the mapper timezone, i.e. 'mapper.setTimeZone(yourTimezone)'");
9099
for (String propertyName : ConfigProvider.getConfig().getPropertyNames()) {
91100
if (propertyName.startsWith("quarkus.jackson.") && !acceptableConfigs.contains(propertyName)) {
92101
String okValue = expectedDefaults.get(propertyName);
93102
if (okValue != null && !okValue
94103
.equalsIgnoreCase(ConfigProvider.getConfig().getConfigValue(propertyName).getRawValue())) {
95104
causes.add("Detected '" + propertyName + "' property set to '"
96105
+ ConfigProvider.getConfig().getConfigValue(propertyName).getRawValue() + "'. "
97-
+ "For ObjectMapper being compatible with the clean, default one the expected value is: '"
98-
+ okValue + "'.");
106+
+ "For your custom ObjectMapper to be compatible with this configuration: "
107+
+ actionsToTake.get(propertyName) + ".");
99108
}
100109
}
101110
}
@@ -130,7 +139,8 @@ public List<String> apply(ArcContainer container) {
130139

131140
// JSON-B was potentially customized
132141
causes.add("Detected '" + handle.getBean().getBeanClass().getName() + "' bean registered. "
133-
+ "It may have customized the Jsonb in a way not compatible with the default one.");
142+
+ "It may have customized the Jsonb in a way not compatible with the default one. "
143+
+ "Review the customizer and apply customizations you need for the database serialization/deserialization of JSON fields to your custom Jsonb.");
134144
}
135145

136146
// JSON-B does not have the config properties so nothing else to check..

0 commit comments

Comments
 (0)