XEdwin / jcouchdb

Automatically exported from code.google.com/p/jcouchdb
Other
0 stars 0 forks source link

org.svenson.JSONParseException: Cannot set property ok on class java.util.ArrayList #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Cannot bulk load docs
2.
3.

What is the expected output? What do you see instead?
NOTE: The data ends up in the database but the return is causing issues!

Exception in thread "main" org.svenson.JSONParseException: Cannot set
property ok on class java.util.ArrayList
    at org.svenson.JSONParser.parseObjectInto(JSONParser.java:571)
    at org.svenson.JSONParser.parse(JSONParser.java:385)
    at org.svenson.JSONParser.parse(JSONParser.java:367)
    at org.jcouchdb.db.Response.getContentAsBean(Response.java:158)
    at org.jcouchdb.db.Database.bulkCreateDocuments(Database.java:387)
    at org.jcouchdb.db.Database.bulkCreateDocuments(Database.java:321)
    at com.marc.XStreamDomParser.main(XStreamDomParser.java:136)

What version of the product are you using? On what operating system?
jcouchdb-0.10.0-3.jar
svenson-1.3.6-dev.jar
OS Linux 2.6.27.23-0.1-default x86_64
openSUSE 11.1 (x86_64)

Please provide any additional information below.
This does not work->
final int num_docs = 1000;
                List<BaseDocument> documents = new ArrayList<BaseDocument>(num_docs);
                for (int i=0; i < num_docs; i++)
                {
                    BaseDocument doc = new BaseDocument();
                    doc.setProperty("data", "The quick brown fox jumps over the
lazy dog.");
                    doc.setId(null);
                    doc.setRevision(null);
                    documents.add(doc);
                }

                db.bulkCreateDocuments(documents);

Original issue reported on code.google.com by mike.gb...@gmail.com on 18 Feb 2010 at 3:46

GoogleCodeExporter commented 9 years ago
It appears that the bugs are in the svenson library and not the couchdb.  I was 
able
to get the code above to work above by modifying this method: parseObjectInto 
in the
class: org.svenson.JSONParser.  

I need to study the code a bit before posting to the svenson site.

I also modified the method: expect in org.svenson.tokenize.Token

See attached file for more details...

Original comment by mike.gb...@gmail.com on 19 Feb 2010 at 2:40

Attachments:

GoogleCodeExporter commented 9 years ago
This doesn't look like a bug in svenson to me.

First of all, it's right: There is no property "ok" in java.util.ArrayList. The
question is why is there an "ok", when it thinks it's parsing an array?

(The bulk creation tests in jcouchdb still work, btw..)

which couchdb version are you using? 

can you set the detail for org.apache.http.headers logger to DEBUG?

if you're using log4j, this would be done like 

log4j.logger.org.apache.http.headers=DEBUG

If you run your code again it should then log the actual HTTP headers jcouchdb 
is
sending and receiving. Maybe that's going to help.

Original comment by ff...@gmx.de on 19 Feb 2010 at 5:30

GoogleCodeExporter commented 9 years ago
copy of a comment in the svenson issues:

bulk support is generally supported, as evidenced by multiple test cases. There 
might
be a real bug hidden somewhere but I need more details to tell more.

As I said in the jcouchdb issue. This is not a svenson bug. 

I see no way that the svenson code passes all svenson and jcouchdb test cases 
but
suddenly starts phantasizing about non-existing "ok" properties in ArrayList.

The bug also does not happen on the way to couchdb but during the parsing of 
couchdb
answer. 

So somewhere there is a reason why your test case differs from the behaviour 
tested
to be correctl in the jcouchdb test cases. Another couchdb version, another 
option,
some special case behaviour etc. With the current information I cannot say more.

Original comment by ff...@gmx.de on 24 Feb 2010 at 3:58

GoogleCodeExporter commented 9 years ago
{{{
package org.jcouchdb;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

import java.util.ArrayList;
import java.util.List;

import org.jcouchdb.db.Database;
import org.jcouchdb.db.LocalDatabaseTestCase;
import org.jcouchdb.document.BaseDocument;
import org.jcouchdb.document.DocumentInfo;
import org.junit.Test;

public class BulkWriteBugTestCase
{
    @Test
    public void test()
    {
        Database db = LocalDatabaseTestCase.recreateDB("bulk-bug");

        final int num_docs = 1000;
        List<BaseDocument> documents = new ArrayList<BaseDocument>(num_docs);
        for (int i=0; i < num_docs; i++)
        {
            BaseDocument doc = new BaseDocument();
            doc.setProperty("data", "The quick brown fox jumps over the lazy dog.");
            doc.setId(null);
            doc.setRevision(null);
            documents.add(doc);
        }

        List<DocumentInfo> infos = db.bulkCreateDocuments(documents);
        assertThat(infos, is(notNullValue()));
        assertThat(infos.size(), is(num_docs));

    }

}

}}}

This test passes for me.

Original comment by ff...@gmx.de on 24 Feb 2010 at 5:05

GoogleCodeExporter commented 9 years ago
I just commented again on the svenson site with a trace of a debug session.  If 
I do 
an update on the trunk of both projects I still get the exception.  The test 
above 
is not in the trunk of couchdb???

Just so I can put this behind me and stop bothering you guys what version of 
couchdb 
and svenson should include???

Original comment by mike.gb...@gmail.com on 24 Feb 2010 at 5:29

GoogleCodeExporter commented 9 years ago
The WritePerf test was @Ignored because it is pretty pointless as a test but I 
wanted
to keep it nevertheless

the tests I meant are
org.jcouchdb.db.LocalDatabaseTestCase.thatBulkCreationWithIdsWorks() etc

all svenson and jcouchdb tests work fine for me with the current SVN trunk of
jcouchdb and the svenson 1.3.6, which is still the current trunk, too

couchdb version is 0.10.0 (the one with ubuntu karmic)

haven't got 0.10.1 to build on my system and I'm still pretty tight on time 
jobwise.

Original comment by ff...@gmx.de on 24 Feb 2010 at 6:51

GoogleCodeExporter commented 9 years ago
I'm starting to get the suspicion that you're using 0.10.1 and the CouchDB 
team, in
it's infinite wisdom decided to suddenly break the response of bulk 
creates/updates
in between 0.10.0 and 0.10.1 without even bothering to add it to the "Breaking
Changes" wiki page.

Original comment by ff...@gmx.de on 24 Feb 2010 at 7:37

GoogleCodeExporter commented 9 years ago
I'm using couchdb 0.8.1...could this be a problem?

If it is I apologize for not adding that piece to the original post.  I just 
thought 
it would give you piece of mind :)

I was able to get all my data loaded by modifying the svenson code, but this is 
not 
optimal.  I'm currently in R&D mode, so it doesn't matter too much.  Plus, 
getting 
couchdb and all it's dependencies built and installed on my Linux box was not a 
simple task. 

Do these number sound close?  Loaded 12,122 5k records in 58 seconds?  It's 
around 
209 recs/second.  I used a batch size of 200, but have not optimized the id's 
yet...

Original comment by mike.gb...@gmail.com on 25 Feb 2010 at 10:10

GoogleCodeExporter commented 9 years ago
oh.. the last version meant to be run against 0.8.1 was
http://jcouchdb.googlecode.com/files/jcouchdb-0.7.2.jar -- that was even before 
the
naming convention change.

But it is really old and nothing was back-ported (so it lacks many features).

I'll close this now.

Original comment by ff...@gmx.de on 25 Feb 2010 at 10:16