[MAGNOLIA-3737] ClassCastException when calling DefaultContent.setNodeData with an integer Created: 17/Jun/11  Updated: 19/Aug/11  Resolved: 18/Aug/11

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: None
Fix Version/s: 4.4.5

Type: Bug Priority: Major
Reporter: Magnolia International Assignee: Daniel Lipp
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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
Date of First Response:

 Description   

Because this method calls info.magnolia.cms.util.NodeDataUtil#getJCRPropertyType then info.magnolia.cms.util.NodeDataUtil#setValue. The former call returns PropertyType.LONG whether the argument value is a java.lang.Integer or java.lang.Long (or their primitive counterparts thanks to auto-boxing), while the latter attempts to cast the value into a Long



 Comments   
Comment by Jan Haderka [ 15/Aug/11 ]

While fixing setValue() could you fix also createValue() (there are 2 of them). I would even suggest to re-factor the code as those methods are doing essentially same thing, but since it will get deprecated soon, probably makes no sense for minor release.
And while at it, there is same issue for double vs. float which should be fixed as well in all 3 methods.

Comment by Daniel Lipp [ 18/Aug/11 ]

1.) createValue(String, int, ValueFactory) didn't need to be adapted: as the int is the PropertyType there's now way to use it with int or floats
2.) no refactoring as it's not that obvious and hence not worth the effort (as stated before - will be deprecated anyway)

Generated at Mon Feb 12 03:49:12 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.