[MAGNOLIA-5864] Inconsistent getter/setter types aren't working with Node2Bean under Java 8 Created: 04/Aug/14  Updated: 18/Jun/15  Resolved: 04/Aug/14

Status: Closed
Project: Magnolia
Component/s: node2bean
Affects Version/s: None
Fix Version/s: 5.3.2

Type: Bug Priority: Neutral
Reporter: Magnolia International Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: java8
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-5535 Enable to run with Java 8 Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 Description   

Java 8 has a slightly different JavaBeans implementation, leading to the propertyType of a java.beans.PropertyDescriptor being null when a getter/setter don't take/return the exact same type AND that property is declared on a parent class of the one we're introspecting. Don't ask me why.
When introspecting classes with org.apache.commons.beanutils.PropertyUtils#getPropertyDescriptors, which in turn uses java.beans.Introspector and returns arrays of java.beans.PropertyDescriptor, if getter and setter use different type (e.g setter takes a narrower type), and we're introspecting a subclass of the class where the property in question is declared:

  • With Java 6: only the propertyType and readMethod are seen; node2bean won't be able to set the property without a writeMethod.
    • if there is an add method, then that's used instead of the writeMethod and all is well.
  • With Java 8: only the readMethod and writeMethod are seen, but propertyType isn't.
    • if there is an add method, then that's used instead of the writeMethod and all is well.

Generated at Mon Feb 12 04:09:06 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.