Dozer 5.5.1 is now case sensitive?

959 views
Skip to first unread message

rhs...@gmail.com

unread,
Aug 14, 2014, 11:20:46 AM8/14/14
to dozer-...@googlegroups.com
I am trying to upgrade to the latest Dozer release, but I discovered the behavior has changed with respect to case sensitivity towards read/write method names. I didn't see this in the release notes and it would seem to be a rather significant shift in the program's behavior. Is there a configuration flag that can be adjusted to restore the prior (5.4.0 and earlier) behavior?

If you run the example below with version 5.4.0:

[exec:exec]
8 [main] INFO org.dozer.config.GlobalSettings - Trying to find Dozer configuration file: dozer.properties
15 [main] WARN org.dozer.config.GlobalSettings - Dozer configuration file not found: dozer.properties.  Using defaults for all Dozer global properties.
17 [main] INFO org.dozer.DozerInitializer - Initializing Dozer. Version: 5.4.0, Thread Name: main
201 [main] INFO org.dozer.jmx.JMXPlatformImpl - Dozer JMX MBean [org.dozer.jmx:type=DozerStatisticsController] auto registered with the Platform MBean Server
202 [main] INFO org.dozer.jmx.JMXPlatformImpl - Dozer JMX MBean [org.dozer.jmx:type=DozerAdminController] auto registered with the Platform MBean Server
206 [main] INFO org.dozer.DozerBeanMapper - Initializing a new instance of dozer bean mapper.
This is from the upper case bean

Now, if we re-run this with version 5.5.1 (curiously identifying itself as 5.5.0?):

10 [main] INFO org.dozer.config.GlobalSettings - Trying to find Dozer configuration file: dozer.properties
17 [main] WARN org.dozer.config.GlobalSettings - Dozer configuration file not found: dozer.properties.  Using defaults for all Dozer global properties.
20 [main] INFO org.dozer.DozerInitializer - Initializing Dozer. Version: 5.5.0, Thread Name: main
204 [main] INFO org.dozer.jmx.JMXPlatformImpl - Dozer JMX MBean [org.dozer.jmx:type=DozerStatisticsController] auto registered with the Platform MBean Server
206 [main] INFO org.dozer.jmx.JMXPlatformImpl - Dozer JMX MBean [org.dozer.jmx:type=DozerAdminController] auto registered with the Platform MBean Server
207 [main] INFO org.dozer.DozerBeanMapper - Initializing a new instance of dozer bean mapper.
null

There is a null value in the destination bean where I would have expected the mapped value to have been stored. Any ideas on this one?


Minimal working example:

import org.dozer.DozerBeanMapper;

public class App {

    public static void main(String[] args) {
        DozerBeanMapper mapper = new DozerBeanMapper();
        UpperCaseBean src = new UpperCaseBean();
        src.setMYSTRING("This is from the upper case bean");
        LowerCaseBean dst = new LowerCaseBean();
        mapper.map(src, dst);
        System.out.println(dst.getmystring());
    }

    public static class UpperCaseBean {

        private String MYSTRING;

        public String getMYSTRING() {
            return MYSTRING;
        }

        public void setMYSTRING(String MYSTRING) {
            this.MYSTRING = MYSTRING;
        }
    }

    public static class LowerCaseBean {

        private String mystring;

        public void setmystring(String mystring) {
            this.mystring = mystring;
        }

        public String getmystring() {
            return this.mystring;
        }
    }
}

Alan Gibson

unread,
Sep 17, 2014, 2:53:27 AM9/17/14
to dozer-...@googlegroups.com
I can confirm this behavior on Dozer 5.5.1. I've opened a ticket: https://github.com/DozerMapper/dozer/issues/195.

The workaround seems to be to name the field in the mapping. Strangely, case doesn't seem to matter. For example, with the following mapping, the "mystring" field will not be mapped:

  <mapping> 
    <class-a>UpperCaseBean</class-a> 
    <class-b>LowerCaseBean</class-b>
  </mapping>

However, with the following mapping, the field "mystring" *will* be mapped:

  <mapping> 
    <class-a>UpperCaseBean</class-a> 
    <class-b>LowerCaseBean</class-b>
    <field>
        <a>mystring</a>
        <b>mystring</b>
    <field>
  </mapping>
Reply all
Reply to author
Forward
0 new messages