SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-898
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Arif Ul Hussain
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Compass undergoes stack overflow when using a mapping of an object inside an object for jsonobject mapping

Created: 02/Sep/09 06:51 AM   Updated: 14/Sep/09 11:56 AM
Component/s: Compass::Core
Affects Version/s: 2.2.0 GA
Fix Version/s: 2.3.0 beta1

Environment:
Operating system: Linux 2.6.28-13-generic #45-Ubuntu i686 GNU/Linux


 Description  « Hide
When using a mapping of a rootobject ( having an object inside it ) for jsonobject . Compass undergoes stack overflow

The mapping file content which gives the stack overflow error is: ( filename is Company.cpm.xml)
****************************************************************************************
<compass-core-mapping>
<root-json-object alias="Company">
<json-id name="id" />
<json-object name="employee">
<json-property name="guid"/>
<json-property name="version"/>
<json-property name="creationdate"/>
<json-object name="address"> // Comment: Object inside object , this will give stack overflow error
<json-property name="street"/>
</json-object>
<json-property name="first_name"/>
<json-property name="last_name"/>
</json-object>
<json-content name="content" />
</root-json-object>
</compass-core-mapping>
***********************************************************************************************************

If we remove the object inside rootobject , the resulting mapping file will not give error, the resulting mapping file is as below : ( filename is Company.cpm.xml)
******************************************************************************
<compass-core-mapping>
<root-json-object alias="Company">
<json-id name="id" />
<json-object name="employee">
<json-property name="guid"/>
<json-property name="version"/>
<json-property name="creationdate"/>
<json-property name="first_name"/>
<json-property name="last_name"/>
</json-object>
<json-content name="content" />
</root-json-object>
</compass-core-mapping>
*******************************************************************************************

The line in the code which gives error is:
config = new CompassConfiguration().configure().addFile(<path to above file>);

The Stackoverflow error is as below
Exception in thread "Thread-33" java.lang.StackOverflowError
at java.util.ArrayList$Itr.<init>(ArrayList.java:743)
at java.util.ArrayList$Itr.<init>(ArrayList.java:743)
at java.util.ArrayList.iterator(ArrayList.java:737)
at org.compass.core.mapping.support.AbstractMultipleMapping.mappingsIt(AbstractMultipleMapping.java:80)
at org.compass.core.mapping.support.AbstractMultipleMapping.copy(AbstractMultipleMapping.java:102)
at org.compass.core.mapping.json.PlainJsonObjectMapping.copy(PlainJsonObjectMapping.java:38)
at org.compass.core.mapping.support.AbstractMultipleMapping.copy(AbstractMultipleMapping.java:103)
at org.compass.core.mapping.json.PlainJsonObjectMapping.copy(PlainJsonObjectMapping.java:38)



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 07/Sep/09 03:27 PM
I have committed a fix and kicked in a nightly build of trunk (2.3). Can you give it a go (in 30 minutes)?

Arif Ul Hussain added a comment - 10/Sep/09 06:14 AM
Hi Shay,

sorry for late reply , i could not get notification of the update ..

I took the following compass changes for the fix and did a build

  • /trunk/src/main/src/org/compass/core/config/binding/PlainMappingBinding.java (version 3922)
  • /trunk/src/main/test/org/compass/core/test/json/object/mapping.cpm.xml (version 3922)

i could see that you have made a code change in the file PlainMappingBinding.java and have included the above reported structure in the file mapping.cpm.xml. as rootobject "d" .....
The tests are all passing but i did not see the file "mapping.cpm.xml" being used anywhere ( for initialisation for indexing)...
Instead, the file SimpleJsonObjectBuilderTests.java uses the following code to initialise the mapping

conf.addMapping(
json("c")
.add(id("id"))
.add(property("value"))
.add(object("obj").add(property("objValue1").namingType(Naming.FULL).valueConverter("int")).add(array("arr").element(property().namingType(Naming.FULL).valueConverter("int"))))

Now ,
Here if we add the mapping for object "d" as
conf.addMapping(
json("d")
.add(id("id"))
.add(object("employee").add(property("guid")).add(property("version")).add(property("creationdate")).add(object("address").add(property("street"))))
.add(content("content"))

the test will pass .....
but if i use the mapping file instead and add the mapping using :
config = config.configure().addFile(<path to mapping.cpm.xml>);
then compass goes to stack overflow error( because of the rootobject "d" which has an object inside object )

Conclusion: if we make the mapping using programmatic builder API ( eg , conf.addMapping(json(d).add ....... ) , then a structure which has an object inside object works well ... but if we make the same mapping using fully explicit mappings ( eg <json-rootobject alias="d" ... ) then compass goes into stack overflow error.

The error still persists..

Please let me know if you need any more information.

Regards


Shay Banon added a comment - 10/Sep/09 01:05 PM
I have ran SimpleJsonObjectTests which does loads the mentioned mapping file. I recreated the stack overflow exception, and fixed it in the commit.

Just for kicks, I added the same programmatic to SimpleJsonObjectBuilderTests and it passes as well. I also added an actual test to verify the indexing work.

Can you simply double check with trunk?


Arif Ul Hussain added a comment - 11/Sep/09 01:54 AM
Hi Shay,

the problem still seems to persist.
Whenever i use config = config.configure().addFile(<path to mapping.cpm.xml>); , compass goes to stack overflow.

btw, in the change log i could find the following files that are changed, but all the below 3 files looks like to be part of test suite and not part of the fix ... am i missing something ???

  • /trunk/src/main/test/org/compass/core/test/json/object/SimpleJsonObjectTests.java (version 3923)
  • /trunk/src/main/test/org/compass/core/test/json/object/SimpleJsonObjectBuilderTests.java (version 3923)
  • /trunk/src/main/test/org/compass/core/test/json/object/mapping.cpm.xml (version 3923)

The above 3 files are the only changes that i took from yestarday's build .. It is very likely that i might missing the files which have the actual fix..
Please let me know the actual files to pick for the fix ..

Thanks and Regards


Shay Banon added a comment - 11/Sep/09 11:58 AM
Hi,

This is very strange. The changes I did are indeed just changes to the testing to test the mapping you gave more properly. When I run the tests, they pass, so I don't really understand what does not pass for you.

Shay


Arif Ul Hussain added a comment - 12/Sep/09 07:01 AM
Hi Shay,

I really appologise for the inconvenience caused ...iam not getting the stack overflow error now ... I was using a wrong value for classpath( which was taking compass2.2.0 instead of your trunk build )

Thanks a lot for your time on the issue ..
Should i close the bug 898 ?

Thanks a lot again....

Regards


Shay Banon added a comment - 14/Sep/09 11:56 AM
No problem, I should thank you for spotting this bug and helping fix it!