Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findAll(Iterable<ID> ids) in CrudRepository throws java.util.concurrent.ExecutionException [DATACOUCH-50] #365

Closed
spring-projects-issues opened this issue Nov 27, 2013 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link

deepak vohra opened DATACOUCH-50 and commented

The other methods in CrudRepository do not generate an exception , but the findAll(Iterable<ID> ids) method generates the following exception with the example from https://github.com/spring-projects/spring-data-couchbase

Exception in thread "main" java.lang.RuntimeException: Failed to access the view
at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:759)
at org.springframework.data.couchbase.core.CouchbaseTemplate$5.doInBucket(CouchbaseTemplate.java:196)
at org.springframework.data.couchbase.core.CouchbaseTemplate$5.doInBucket(CouchbaseTemplate.java:192)
at org.springframework.data.couchbase.core.CouchbaseTemplate.execute(CouchbaseTemplate.java:234)
at org.springframework.data.couchbase.core.CouchbaseTemplate.queryView(CouchbaseTemplate.java:192)
at org.springframework.data.couchbase.core.CouchbaseTemplate.findByView(CouchbaseTemplate.java:179)
at org.springframework.data.couchbase.repository.support.SimpleCouchbaseRepository.findAll(SimpleCouchbaseRepository.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:344)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:329)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.data.couchbase.repository.support.ViewPostProcessor$ViewInterceptor.invoke(ViewPostProcessor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.findAll(Unknown Source)
at service.CatalogService.findAllDocumentsByCollection(CatalogService.java:103)
at service.CatalogService.main(CatalogService.java:62)
Caused by: java.util.concurrent.ExecutionException: OperationException: SERVER: bad_request Reason: invalid UTF-8 JSON: error,{2,"lexical error: invalid char in json text.\n",
"[catalog:engineering-as-a-service, catalog:quintessential-and-collaborative]"}
at com.couchbase.client.internal.HttpFuture.waitForAndCheckOperation(HttpFuture.java:98)
at com.couchbase.client.internal.ViewFuture.get(ViewFuture.java:65)
at com.couchbase.client.internal.ViewFuture.get(ViewFuture.java:49)
at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:72)
at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:752)
... 21 more
Caused by: OperationException: SERVER: bad_request Reason: invalid UTF-8 JSON: error,{2,"lexical error: invalid char in json text.\n",
"[catalog:engineering-as-a-service, catalog:quintessential-and-collaborative]"}
at com.couchbase.client.protocol.views.DocsOperationImpl.parseError(DocsOperationImpl.java:105)
at com.couchbase.client.protocol.views.ViewOperationImpl.handleResponse(ViewOperationImpl.java:68)
at com.couchbase.client.ViewNode$MyHttpRequestExecutionHandler.handleResponse(ViewNode.java:225)
at org.apache.http.nio.protocol.AsyncNHttpClientHandler.processResponse(AsyncNHttpClientHandler.java:417)
at org.apache.http.nio.protocol.AsyncNHttpClientHandler.inputReady(AsyncNHttpClientHandler.java:242)
at com.couchbase.client.http.AsyncConnectionManager$ManagedClientHandler.inputReady(AsyncConnectionManager.java:249)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:172)
at org.apache.http.impl.nio.DefaultClientIOEventDispatch.inputReady(DefaultClientIOEventDispatch.java:155)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:161)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:335)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:275)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:542)
at java.lang.Thread.run(Thread.java:722)


No further details from DATACOUCH-50

@spring-projects-issues
Copy link
Author

Michael Nitschinger commented

This exception originates on the server side, it shows that you have invalid chars in your documents. Can you pinpoint this document and send it along? Has it been stored through spring-data-couchbase? If so we should make sure they can't go through

@spring-projects-issues
Copy link
Author

deepak vohra commented

Why don't the other methods in CrudRepository, including findOne and findAll, on the same document generate an exception if the document has invalid chars? The documents are added with save(Iterable<S> entities) method. The example used is

ArrayList arrayList = new ArrayList();
Catalog catalog1 = new Catalog("Oracle_Magazine", "Oracle_Publishing",
"November-December_2013", "Engineering as a Service",
"David_A._Kelly");

Catalog catalog2 = new Catalog("Oracle_Magazine", "Oracle_Publishing",
          "11/12_2013", "Engineering_as_a_Service", "Kelly, David");
arrayList.add(catalog1);
arrayList.add(catalog2);
repository.save(arrayList);

The generated JSON is
{
"journal": "Oracle_Magazine",
"author": "David_A._Kelly",
"edition": "November-December_2013",
"title": "Engineering as a Service",
"_class": "com.couchbase.model.Catalog",
"publisher": "Oracle_Publishing"
}

and:
{
"journal": "Oracle_Magazine",
"author": "Kelly, David",
"edition": "11/12_2013",
"title": "Engineering_as_a_Service",
"_class": "com.couchbase.model.Catalog",
"publisher": "Oracle_Publishing"
}

@spring-projects-issues
Copy link
Author

deepak vohra commented

Even if the document fields are empty except the Id an exception is generated.

For example,

Catalog catalog1 = new Catalog("", "",
"", "Engineering as a Service",
"");

Catalog catalog2 = new Catalog("", "",
          "", "Engineering_as_a_Service", "");
arrayList.add(catalog1);
arrayList.add(catalog2);
repository.save(arrayList);

The following code snippet generates an exception.

ArrayList arrayList = new ArrayList();
arrayList.add("catalog:engineering-as-a-service");
arrayList.add("catalog:engineering_as_a_service");

Iterable<Catalog> iterable = repository.findAll(arrayList);

@spring-projects-issues
Copy link
Author

deepak vohra commented

Even the following documents, which don't have very many chars,generate an exception.

Save with:
Catalog catalog1 = new Catalog("", "",
"", "a",
"");

Catalog catalog2 = new Catalog("", "",
          "", "b", "");
arrayList.add(catalog1);
arrayList.add(catalog2);
repository.save(arrayList);

Find with:

arrayList.add("a");
arrayList.add("b");

Iterable<Catalog> iterable = repository.findAll(arrayList);
Iterator<Catalog> iter = iterable.iterator();

@spring-projects-issues
Copy link
Author

deepak vohra commented

The exception is generated due an invalid char in the JSON generated for the request and is not related to JSON stored in the datastore

@spring-projects-issues
Copy link
Author

Michael Nitschinger commented

I tried the code and it works without issues.

Also note that the findAll() method doesn't work this way as described here. No argument is supported there, if you want a custom method you need to add one to your interface with a Query param.

Please reopen if you still have issues with the current master, and if possible provide a complete code example with data and server version that I can reproduce.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants