Bug 1073486 - Restapi throws ClassCastException when search by unknow value
Summary: Restapi throws ClassCastException when search by unknow value
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-api
Version: 3.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 3.4.0
Assignee: Juan Hernández
QA Contact: Pavel Stehlik
URL:
Whiteboard: infra
Depends On:
Blocks: 1024889 1073359
TreeView+ depends on / blocked
 
Reported: 2014-03-06 14:08 UTC by Juan Hernández
Modified: 2014-03-31 08:24 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1073359
Environment:
Last Closed: 2014-03-31 08:24:59 UTC
oVirt Team: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 25464 0 None None None Never
oVirt gerrit 25480 0 None MERGED restapi: Don't assume that Lists are ArrayLists Never
oVirt gerrit 25512 0 None MERGED restapi: Don't assume that Lists are ArrayLists Never

Description Juan Hernández 2014-03-06 14:08:50 UTC
+++ This bug was initially created as a clone of Bug #1073359 +++

Description of problem:


Version-Release number of selected component (if applicable):
av2

How reproducible:
always

Steps to Reproduce:
1. /api/domains/6272712d-6970-612e-7268-65762e6c6162/users?search=abcdefg=123456

Actual results:
<fault><reason>Operation Failed</reason><detail>Cannot cast java.util.Collections$EmptyList to java.util.ArrayList</detail></fault>

Expected results:
<users/>

Additional info:
2014-03-06 10:34:17,768 INFO  [org.ovirt.engine.core.bll.LoginUserCommand] (ajp-/127.0.0.1:8702-11) Running command: LoginUserCommand internal: false.
2014-03-06 10:34:17,790 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (ajp-/127.0.0.1:8702-11) Correlation ID: null, Call Stack: null, Custom Event ID: -1, Message: User admin logged in.
2014-03-06 10:34:17,792 WARN  [org.ovirt.engine.core.bll.SearchQuery] (ajp-/127.0.0.1:8702-11) ResourceManager::searchBusinessObjects - erroneous search text - ADUSER: abcdefg=123456
2014-03-06 10:34:17,792 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (ajp-/127.0.0.1:8702-11) Operation Failed: Cannot cast java.util.Collections$EmptyList to java.util.ArrayList: java.lang.ClassCastException: Cannot cast java.util.Collections$EmptyList to java.util.ArrayList
	at java.lang.Class.cast(Class.java:3005) [rt.jar:1.7.0_09-icedtea]
	at org.ovirt.engine.api.restapi.resource.BackendResource.getEntity(BackendResource.java:65) [restapi-jaxrs.jar:]
	at org.ovirt.engine.api.restapi.resource.BackendDomainUsersResource.getDomainUsers(BackendDomainUsersResource.java:80) [restapi-jaxrs.jar:]
	at org.ovirt.engine.api.restapi.resource.BackendDomainUsersResource.list(BackendDomainUsersResource.java:99) [restapi-jaxrs.jar:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_09-icedtea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_09-icedtea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_09-icedtea]
	at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_09-icedtea]
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:159) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:107) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:154) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:92) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec.jar:1.0.2.Final-redhat-1]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.ovirt.engine.core.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:80) [common.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:499) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web.jar:7.3.2.Final-redhat-1]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:488) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:420) [jbossweb.jar:7.2.2.Final-redhat-1]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb.jar:7.2.2.Final-redhat-1]
	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09-icedtea]

2014-03-06 10:34:17,797 INFO  [org.ovirt.engine.core.bll.LogoutUserCommand] (ajp-/127.0.0.1:8702-11) [739775d6] Running command: LogoutUserCommand internal: false.
2014-03-06 10:34:17,807 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (ajp-/127.0.0.1:8702-11) [739775d6] Correlation ID: 739775d6, Call Stack: null, Custom Event ID: -1, Message: User admin logged out.

--- Additional comment from RHEL Product and Program Management on 2014-03-06 04:41:49 EST ---

This bug report has Keywords: Regression or TestBlocker.

Since no regressions or test blockers are allowed between releases,
it is also being identified as a blocker for this release.

Please resolve ASAP.

--- Additional comment from Juan Hernández on 2014-03-06 05:19:46 EST ---

This happens because in some parts of the RESTAPI we assume that the lists returned by the backend are ArrayLists. After the directory refactoring the backend returns an special implementation of the List interfaces for empty lists, the result of Collections.emptyList(), and that isn't an ArrayList. We need to stop assuming that the backend returns ArrayLists, and use the List interface instead. That is what the proposed patch is doing, for the particular case of this bug and for a couple of other cases.

Comment 1 Juan Hernández 2014-03-06 14:10:28 UTC
This issue was detected in RHEV-M 3.4, but it also affects oVirt Engine 3.4.

Comment 2 Juan Hernández 2014-03-07 08:33:08 UTC
Itamar, I discussed this bug with Sandro and we agreed that it is important enough to have it in 3.4.0. Why do you think it shouldn't?

Comment 3 Juan Hernández 2014-03-07 08:36:08 UTC
Ok, I saw your comment in the change in gerrit. I'm retargeting to 3.4.0, as the original intention was to have it there.


Note You need to log in before you can comment on or make changes to this bug.