Small but significant proposed change to detection of `getxxx()` (vs `getXxx()`), Bean naming convention

9 views
Skip to first unread message

Tatu Saloranta

unread,
May 19, 2020, 7:29:54 PM5/19/20
to jackson-user, jacks...@googlegroups.com
So, a bug was reported as:

https://github.com/FasterXML/jackson-databind/issues/2729

which is related to problems in Jackson scala module 2.10 handling
auto-detection, and uncovering what seems like a small but significant
deviation from Bean Naming: Jackson not requiring that the first
character following "get" and "set" prefix is upper-case, to
auto-detect getter/setter.

So: Jackson will detect accessors like

public int getxxx() { ... }
public void set_value(int x) { .... }

which are probably not compatible with Bean Naming as originally defined.

My first thought was that this is more a feature than bug, since I
suspect there are users expecting this behavior.
As such, a change should be by adding a new `MapperFeature` to allow
opt-in, defaulting to using old logic for 2.x (but change in 3.0)

But then I remembered that there is already
`MapperFeature.USE_STD_BEAN_NAMING` that could be used here too.

WDYT? I seem to be oscillating between two states here, and wanted to
hear how others feel about proposed change.

-+ Tatu +-

PJ Fanning

unread,
Jun 8, 2020, 12:42:17 PM6/8/20
to jackson-dev
Seems like the right way to go to me.

Michael

unread,
Jun 9, 2020, 1:01:15 AM6/9/20
to jacks...@googlegroups.com
Agree, this seems fine to me too.

My first thought was that this is more a feature than bug, since I
suspect there are users expecting this behavior.


No doubt!

--
You received this message because you are subscribed to the Google Groups "jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-dev/019e1c33-5b46-4516-8b72-703ebcbc9c0bo%40googlegroups.com.


--
Written on a glass keyboard.

Tatu Saloranta

unread,
Jun 9, 2020, 12:12:13 PM6/9/20
to jacks...@googlegroups.com
Ok thank you both for comments. I am still trying to think this
through -- although mostly just preoccupied with bigger work on
"CoercionConfigs" -- so haven't done actual work.

I am also considering possibility of creating one or more new
`XxxConfig`s (initially `JsonNodeConfig`), and figured out an
inexpensive way to make it scale to any (well, small, but not fixed)
number of similar bitfields (BitSet would be fine except they are
mutable, but it's not rocket science to create subset). So it may be
simpler to solve this after figuring out other bigger changes.

-+ Tatu +-
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-dev/CAEBemP1J6cChBC-9MMKEFBJb5ntWzKNs6cO-wzPXP1%2BeGzsb0w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages