@@ -58,7 +58,7 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
5858 * for reasons for deprecation.
5959 */
6060 @ Deprecated // since 2.12
61- public static final PropertyNamingStrategy UPPER_CAMEL_CASE = new UpperCamelCaseStrategy ();
61+ public static final PropertyNamingStrategy UPPER_CAMEL_CASE = new UpperCamelCaseStrategy (false );
6262
6363 /**
6464 * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#SNAKE_CASE} instead.
@@ -67,7 +67,7 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
6767 * for reasons for deprecation.
6868 */
6969 @ Deprecated // since 2.12
70- public static final PropertyNamingStrategy SNAKE_CASE = new SnakeCaseStrategy ();
70+ public static final PropertyNamingStrategy SNAKE_CASE = new SnakeCaseStrategy (false );
7171
7272 /**
7373 * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#LOWER_CASE} instead.
@@ -76,7 +76,7 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
7676 * for reasons for deprecation.
7777 */
7878 @ Deprecated // since 2.12
79- public static final PropertyNamingStrategy LOWER_CASE = new LowerCaseStrategy ();
79+ public static final PropertyNamingStrategy LOWER_CASE = new LowerCaseStrategy (false );
8080
8181 /**
8282 * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#KEBAB_CASE} instead.
@@ -85,7 +85,7 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
8585 * for reasons for deprecation.
8686 */
8787 @ Deprecated // since 2.12
88- public static final PropertyNamingStrategy KEBAB_CASE = new KebabCaseStrategy ();
88+ public static final PropertyNamingStrategy KEBAB_CASE = new KebabCaseStrategy (false );
8989
9090 /**
9191 * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#LOWER_DOT_CASE} instead.
@@ -94,7 +94,7 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
9494 * for reasons for deprecation.
9595 */
9696 @ Deprecated // since 2.12
97- public static final PropertyNamingStrategy LOWER_DOT_CASE = new LowerDotCaseStrategy ();
97+ public static final PropertyNamingStrategy LOWER_DOT_CASE = new LowerDotCaseStrategy (false );
9898
9999 /*
100100 /**********************************************************
@@ -194,6 +194,23 @@ public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParam
194194 @ Deprecated
195195 public static abstract class PropertyNamingStrategyBase extends PropertyNamingStrategy
196196 {
197+ protected PropertyNamingStrategyBase () {
198+ // For use via annotations: WARN
199+ this (true );
200+ }
201+
202+ protected PropertyNamingStrategyBase (boolean logWarning ) {
203+ super ();
204+ if (logWarning ) {
205+ final String simple = getClass ().getSimpleName ();
206+ Logger .getLogger (getClass ().getName ())
207+ .warning (
208+ "PropertyNamingStrategy." +simple +" is used but it has been deprecated due to " +
209+ "risk of deadlock. Consider using PropertyNamingStrategies." +simple +" instead. " +
210+ "See https://github.com/FasterXML/jackson-databind/issues/2715 for more details." );
211+ }
212+ }
213+
197214 @ Override
198215 public String nameForField (MapperConfig <?> config , AnnotatedField field , String defaultName )
199216 {
@@ -276,6 +293,9 @@ protected static String translateLowerCaseWithSeparator(final String input, fina
276293 @ Deprecated // since 2.12
277294 public static class SnakeCaseStrategy extends PropertyNamingStrategyBase
278295 {
296+ public SnakeCaseStrategy () { }
297+ protected SnakeCaseStrategy (boolean logWarning ) { super (logWarning ); }
298+
279299 @ Override
280300 public String translate (String input )
281301 {
@@ -320,19 +340,13 @@ public String translate(String input)
320340 @ Deprecated // since 2.12
321341 public static class UpperCamelCaseStrategy extends PropertyNamingStrategyBase
322342 {
323- public UpperCamelCaseStrategy () {
324- Logger .getLogger (UpperCamelCaseStrategy .class .getName ())
325- .warning (
326- "PropertyNamingStrategy.UpperCamelCaseStrategy is used but it has been deprecated due to " +
327- "risk of deadlock. Consider using PropertyNamingStrategies.UpperCamelCaseStrategy instead. " +
328- "See https://github.com/FasterXML/jackson-databind/issues/2715 for more details." );
329- }
343+ public UpperCamelCaseStrategy () { }
344+ protected UpperCamelCaseStrategy (boolean logWarning ) { super (logWarning ); }
330345
331346 /**
332347 * Converts camelCase to PascalCase
333348 *
334- * For example, "userName" would be converted to
335- * "UserName".
349+ * For example, "userName" would be converted to "UserName".
336350 *
337351 * @param input formatted as camelCase string
338352 * @return input converted to PascalCase format
@@ -363,13 +377,8 @@ public String translate(String input) {
363377 @ Deprecated // since 2.12
364378 public static class LowerCaseStrategy extends PropertyNamingStrategyBase
365379 {
366- public LowerCaseStrategy () {
367- Logger .getLogger (LowerCaseStrategy .class .getName ())
368- .warning (
369- "PropertyNamingStrategy.LowerCaseStrategy is used but it has been deprecated " +
370- "due to risk of deadlock. Consider using PropertyNamingStrategies.LowerCaseStrategy instead. " +
371- "See https://github.com/FasterXML/jackson-databind/issues/2715 for more details." );
372- }
380+ public LowerCaseStrategy () { }
381+ protected LowerCaseStrategy (boolean logWarning ) { super (logWarning ); }
373382
374383 @ Override
375384 public String translate (String input ) {
@@ -386,13 +395,8 @@ public String translate(String input) {
386395 @ Deprecated // since 2.12
387396 public static class KebabCaseStrategy extends PropertyNamingStrategyBase
388397 {
389- public KebabCaseStrategy () {
390- Logger .getLogger (KebabCaseStrategy .class .getName ())
391- .warning (
392- "PropertyNamingStrategy.KebabCaseStrategy is used but it has been deprecated" +
393- "due to risk of deadlock. Consider using PropertyNamingStrategies.KebabCaseStrategy instead. " +
394- "See https://github.com/FasterXML/jackson-databind/issues/2715 for more details." );
395- }
398+ public KebabCaseStrategy () { }
399+ protected KebabCaseStrategy (boolean logWarning ) { super (logWarning ); }
396400
397401 @ Override
398402 public String translate (String input ) {
@@ -409,13 +413,8 @@ public String translate(String input) {
409413 @ Deprecated // since 2.12
410414 public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase
411415 {
412- public LowerDotCaseStrategy () {
413- Logger .getLogger (LowerDotCaseStrategy .class .getName ())
414- .warning (
415- "PropertyNamingStrategy.LowerDotCaseStrategy is used but it has been deprecated" +
416- "due to risk of deadlock. Consider using PropertyNamingStrategies.LowerDotCaseStrategy instead. " +
417- "See https://github.com/FasterXML/jackson-databind/issues/2715 for more details." );
418- }
416+ public LowerDotCaseStrategy () { }
417+ protected LowerDotCaseStrategy (boolean logWarning ) { super (logWarning ); }
419418
420419 @ Override
421420 public String translate (String input ){
0 commit comments