Bug 976786
Summary: | Creating content-based resource ends up with IndexoutOfBoundsException | ||
---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | Libor Zoubek <lzoubek> |
Component: | REST | Assignee: | Heiko W. Rupp <hrupp> |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Mike Foley <mfoley> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 4.8 | CC: | lzoubek, theute |
Target Milestone: | --- | ||
Target Release: | RHQ 4.9 | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2014-03-26 08:32:08 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Libor Zoubek
2013-06-21 13:04:08 UTC
Libor, there is an example of such a resource creation at org.rhq.modules.integrationTests.restApi.ContentTest#testCreatePackageBasedResource can you tell me the difference to your case above? Perhaps even add your failure to the above test class as an additional test? I am sending same data as your test, in fact I've been looking at it when writing my example. I probably found out. I am using requests python client library, which by default follows server redirects. So client immediately follows (because server sends 302 and redirects it to creationStatus). I tried to forbid following redirects by client, and I got empty response with Location header pointing to creationStatus. This url returns new resource after some time (I didn't catch it when it was returning status . so not sure if that really happens) It looks like a findCreatedResource method expects that resource to exist. Weird enough, because calling findCreatedResource happens only when: if (status== CreateResourceStatus.SUCCESS) { ResourceWithType rwt = findCreatedResource(history.getParentResource().getId(),history.getCreatedResourceName(),uriInfo); builder = Response.ok(); setCachingHeader(builder, 600); builder.entity(rwt); } This means then even if creationStatus becomes SUCCESS, there might be a timeslot, when new resource is not yet imported. As an example you can run https://github.com/rhq-project/samples/blob/master/rest-api/python/create_as7_deployment.py Btw, I am not sure, if it is a good idea for GET /rest/creationStatus/<ID> to send 302 when creation is in progress, some clients may be "smart" and detect infinite loop redirects (browsers do that afaik) master 1ceae7f adds a check for SUCCESS status to see if the resource is really there (*1). If not it returns IN_PROGRESS. Sending a 302 is a common pattern to tell a client to return back with a GET request to check for the results of a POST (*2). A 303 code would have been better I guess, but a 302 is ok. See http://en.wikipedia.org/wiki/HTTP_status_code#3xx_Redirection In fact we pause a bit until we respond, so the user should not run into endless recursion with the 302 code. 1) looks like there are timing issues that don't matter when the user is in the UI, as a human is slower than a script 2) Our BZ instance violates that pattern. Bulk closing now that 4.10 is out. If you think an issue is not resolved, please open a new BZ and link to the existing one. |