You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Augustus Thoo (JIRA)" <ji...@apache.org> on 2011/02/10 12:56:57 UTC

[jira] Created: (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

JSONSerializer can't deserialize to BigDecimal
----------------------------------------------

                 Key: PIVOT-704
                 URL: https://issues.apache.org/jira/browse/PIVOT-704
             Project: Pivot
          Issue Type: Bug
          Components: core-beans, core-json, core-serialization
    Affects Versions: 2.0
            Reporter: Augustus Thoo


JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.

Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment:     (was: BeanAdapterTest.java)

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020580#comment-13020580 ] 

Sandro Martini commented on PIVOT-704:
--------------------------------------

Probably I've found the problem (at least in my environment, with Java 6 Update 24 both @32bit and @64 bit):
inside BeanAdapter#PropertyIterator .. it's something related to our usage of reflection (I think).
Or could be a Java bug ... someone is aware of this ?

Some info:
http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getMethods%28%29

In the Test class just created, try to add the following method, and run it in debug mode, setting a breakpoint on the last line in the method.
You'll see that in the returned methods and fields, we should use the second block of instructions ... at least in this case.

    @Test
    public void testReflection()
    {
        Method[] methods = BeanAdapterTestObject.class.getMethods();
        Field[]  fields  = BeanAdapterTestObject.class.getFields();

        Method[] methodsDeclared = BeanAdapterTestObject.class.getDeclaredMethods();
        Field[]  fieldsDeclared  = BeanAdapterTestObject.class.getDeclaredFields();
        
        int i = 0;  // set a breakpoint here
    }
    


Greg (and others), what do you think ?


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Comment: was deleted

(was: Sorry, too much in hurry and made a big mistake (generated getters/setters) ... sorry. 
I'll continue my work on this this week.

Bye,
Sandro
)

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13011194#comment-13011194 ] 

Greg Brown commented on PIVOT-704:
----------------------------------

> Ok, so I have to make some extensive tests on different cases. 

Well yes, but first you need to fix the bugs.  :-)


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020990#comment-13020990 ] 

Sandro Martini commented on PIVOT-704:
--------------------------------------

Hi Greg,
yes, I've just find the right solution (I hope :-) ), in the way you suggested.
But without calling the if instanceof (otherwise during deserialization is will not be able to find the right parameter type for the setter). Shortly this is an extract of the fix:

                } else if (type == BigInteger.class) {
                            coercedValue = new BigInteger(value.toString());
                } else if (type == BigDecimal.class) {
                        coercedValue = new BigDecimal(value.toString());
// TODO: move this as first choice ...  // currently this is here just as a reminder
                } else if (type == String.class) {
                    coercedValue = value.toString();


And last, given the (usually high) frequency of String attributes, I'm thinking to move the if (instanceof String) block as first choice, to have a little speedup, ok ?

Thank you for the moment.
Today/tomorrow I'll commit this fix and related changes to the test case (and resolve the issue), tell me if something is still not working (and/or reopen the ticket).

Bye,
Sandro


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012408#comment-13012408 ] 

Sandro Martini commented on PIVOT-704:
--------------------------------------

Hi Augustus, thank you very much for your tests :-) .

This evening I'll try them and post a new patch so you and others can try and see ...
Let's update later.

Bye


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Issue Comment Edited] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13021000#comment-13021000 ] 

Sandro Martini edited comment on PIVOT-704 at 4/18/11 12:30 PM:
----------------------------------------------------------------

Greg, thanks for the hint, I'll try to follow your suggestions ... maybe I could as first try commit the last patch and then after see how to make the other change (based on your suggestions).

This should solve this ticket (one time test case and related test class will be ok, in next days), so the other (patch_old.patch) has been re-attached here but only as a reference. I'll apply this patch in one/max two days (as soon as possible).

Note that I deleted previous attachments because with some changes they are part of Pivot.
Than you very much to all for the help.


      was (Author: smartini):
    This should be the final patch for this ticket (one time test case and related test class will be ok, in next days), so the other (patch_old.patch) has been re-attached here but only as a reference. I'll apply this patch in one/max two days (as soon as possible).

Note that I deleted previous attachments because with some changes they are part of Pivot.
Than you very much to all for the help.

  
> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_new.patch, patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Issue Comment Edited] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020580#comment-13020580 ] 

Sandro Martini edited comment on PIVOT-704 at 4/18/11 10:18 AM:
----------------------------------------------------------------

Sorry, too much in hurry and made a big mistake (generated getters/setters) ... sorry. 
I'll continue my work on this this week.

Bye,
Sandro


      was (Author: smartini):
    Probably I've found the problem (at least in my environment, with Java 6 Update 24 both @32bit and @64 bit):
inside BeanAdapter#PropertyIterator .. it's something related to our usage of reflection (I think).
Or could be a Java bug ... someone is aware of this ?

Some info:
http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getMethods%28%29

In the Test class just created, try to add the following method, and run it in debug mode, setting a breakpoint on the last line in the method.
You'll see that in the returned methods and fields, we should use the second block of instructions ... at least in this case.

    @Test
    public void testReflection()
    {
        Method[] methods = BeanAdapterTestObject.class.getMethods();
        Field[]  fields  = BeanAdapterTestObject.class.getFields();

        Method[] methodsDeclared = BeanAdapterTestObject.class.getDeclaredMethods();
        Field[]  fieldsDeclared  = BeanAdapterTestObject.class.getDeclaredFields();
        
        int i = 0;  // set a breakpoint here
    }
    


Greg (and others), what do you think ?

  
> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini resolved PIVOT-704.
----------------------------------

    Resolution: Fixed

Just checked in the fix (and the updated JUnit Test case).
Be free to reopen the issue in case of errors.

Sandro


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_new.patch, patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Issue Comment Edited] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020302#comment-13020302 ] 

Sandro Martini edited comment on PIVOT-704 at 4/18/11 10:23 AM:
----------------------------------------------------------------

Yesterday I have committed (under core/test/...) a JUnit Test case to demonstrate the problem (even with my patch).
I've just seen that in next days I have to fix even the test case.
As soon as possible I hope to fix the problem, but I'll post here a new patch before committing.


      was (Author: smartini):
    Yesterday I have committed (under core/test/...) a JUnit Test case to demonstrate the problem (even with my patch).
Probably the test case is not perfect, so some change could be done even on it.
As soon as possible I hope to fix the problem, but I'll post here a new patch before committing.

  
> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020302#comment-13020302 ] 

Sandro Martini commented on PIVOT-704:
--------------------------------------

Yesterday I have committed (under core/test/...) a JUnit Test case to demonstrate the problem (even with my patch).
Probably the test case is not perfect, so some change could be done even on it.
As soon as possible I hope to fix the problem, but I'll post here a new patch before committing.


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment:     (was: TestObject.java)

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment:     (was: patch.patch)

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020986#comment-13020986 ] 

Greg Brown commented on PIVOT-704:
----------------------------------

The problem is simple to fix. In the following code, you are generating a Long when the value is of type Number:

if (value instanceof Number) {
    coercedValue = ((Number)value).longValue();
} else {
    coercedValue = new BigInteger(value.toString());
}

You should be generating a BigInteger. Same for Double.


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Updated: (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Fix Version/s: 2.0.1
         Assignee: Sandro Martini
         Priority: Minor  (was: Major)

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13011191#comment-13011191 ] 

Sandro Martini commented on PIVOT-704:
--------------------------------------

Hi Greg, 
Ok, so I have to make some extensive tests on different cases.
In the meantime if someone has some complex json files please attach here.


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment: patch.patch

patch to fix the behavior, handling BigInteger and BigDecimal.
Note that I guess if it would be better to move the test on type = String as first option, to avoid many if when not needed (assuming the String type it's a common case here).

Tell me what you think.

Bye,
Sandro


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Augustus Thoo (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Augustus Thoo updated PIVOT-704:
--------------------------------

    Attachment: TestObject.java
                BeanAdapterTest.java

This are my JUnit test case files. Run it against pivot-core-2.0.jar to test for Issue PIVOT-704.

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment: patch_new.patch

This should be the final patch for this ticket (one time test case and related test class will be ok, in next days), so the other (patch_old.patch) has been re-attached here but only as a reference. I'll apply this patch in one/max two days (as soon as possible).

Note that I deleted previous attachments because with some changes they are part of Pivot.
Than you very much to all for the help.


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_new.patch, patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13011169#comment-13011169 ] 

Greg Brown commented on PIVOT-704:
----------------------------------

That logic will fail when value is an instance of Number (it will convert to long or double instead of BigInteger and BigDecimal).


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Sandro Martini (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandro Martini updated PIVOT-704:
---------------------------------

    Attachment: patch_old.patch

> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: patch_old.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIVOT-704) JSONSerializer can't deserialize to BigDecimal

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020995#comment-13020995 ] 

Greg Brown commented on PIVOT-704:
----------------------------------

That will work but will result in an unnecessary conversion to String when the value is already a number. You just need to fix the code within the "value instanceof Number" block.

Moving the String check up seems fine.


> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
>                 Key: PIVOT-704
>                 URL: https://issues.apache.org/jira/browse/PIVOT-704
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-beans, core-json, core-serialization
>    Affects Versions: 2.0
>            Reporter: Augustus Thoo
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce double to BigDecimal" when the object class contains at least one BigDecimal field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object, Class) has no else-if for BigDecimal class.
> Re: http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira