Skip to content

Commit 6595974

Browse files
authored
Warn if deprecated subclasses of PropertyNamingStrategy is used (#4144)
1 parent 7008c1b commit 6595974

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/main/java/com/fasterxml/jackson/databind/PropertyNamingStrategy.java

+36-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
66
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
77

8+
import java.util.logging.Logger;
9+
810
/**
911
* Class that defines how names of JSON properties ("external names")
1012
* are derived from names of POJO methods and fields ("internal names"),
@@ -318,6 +320,14 @@ public String translate(String input)
318320
@Deprecated // since 2.12
319321
public static class UpperCamelCaseStrategy extends PropertyNamingStrategyBase
320322
{
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+
}
330+
321331
/**
322332
* Converts camelCase to PascalCase
323333
*
@@ -353,6 +363,14 @@ public String translate(String input) {
353363
@Deprecated // since 2.12
354364
public static class LowerCaseStrategy extends PropertyNamingStrategyBase
355365
{
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+
}
373+
356374
@Override
357375
public String translate(String input) {
358376
return input.toLowerCase();
@@ -368,6 +386,14 @@ public String translate(String input) {
368386
@Deprecated // since 2.12
369387
public static class KebabCaseStrategy extends PropertyNamingStrategyBase
370388
{
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+
}
396+
371397
@Override
372398
public String translate(String input) {
373399
return translateLowerCaseWithSeparator(input, '-');
@@ -381,7 +407,16 @@ public String translate(String input) {
381407
* for reason for deprecation)
382408
*/
383409
@Deprecated // since 2.12
384-
public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase {
410+
public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase
411+
{
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+
}
419+
385420
@Override
386421
public String translate(String input){
387422
return translateLowerCaseWithSeparator(input, '.');

src/moditect/module-info.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Generated 08-Mar-2019 using Moditect maven plugin
22
module com.fasterxml.jackson.databind {
3+
requires java.logging;
34
// required for
45
// java.beans.ConstructorProperties
56
// java.beans.Transient

0 commit comments

Comments
 (0)