DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15004>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15004

BeanUtils.copyProperties goes through wasted processing

           Summary: BeanUtils.copyProperties goes through wasted processing
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Bean Utilities
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The copyProperties method goes through all the properties of a src bean even 
though it might not have a matching property in the destination bean.

For example:

If we have:

public class BeanA
{
  private String a;
  private String c;

  public String getA()
  {
     System.out.println("Getting A");
     return a;
  }

  public String getC()
  {
     System.out.println("Getting C");
     return c;
  }

  public void setA( String a )
  {
     System.out.println("Setting A");
     this.a = a;
  }

  public void setC( String c )
  {
     System.out.println("Setting C");
     this.c = c;
  }
}

and

public class BeanB
{
  private String a;
  private String b;
  private String c;
  private String d;

  public String getA()
  {
     System.out.println("Getting A");
     return a;
  }

  public String getB()
  {
     System.out.println("Getting B");
     return b;
  }

  public String getC()
  {
     System.out.println("Getting C");
     return c;
  }

  public String getD()
  {
     System.out.println("Getting D");
     return d;
  }

  public void setA( String a )
  {
     System.out.println("Setting A");
     this.a = a;
  }

  public void setB( String b )
  {
     System.out.println("Setting b");
     this.b = b;
  }

  public void setC( String c )
  {
     System.out.println("Setting C");
     this.c = c;
  }

  public void setD( String d )
  {
     System.out.println("Setting D");
     this.d = d;
  }
}

using BeanUtils.copyProperties( beanA, beanB ) will show all the "getting B" 
and "getting D" system outs even though those properties do not exist in BeanA.

This results in alot of wasted cycles.

Running this in a loop of 1000 will yield a time ~2x that of just copying the 
needed properties.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to