Claus Ibsen created CAMEL-26270:
-----------------------------------

             Summary: camel-openstack - a producer only works on the thread 
that created it, so a route from a file consumer to swift fails with Unable to 
retrieve current session
                 Key: CAMEL-26270
                 URL: https://issues.apache.org/jira/browse/CAMEL-26270
             Project: Camel
          Issue Type: Bug
          Components: camel-openstack
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of openstack-cinder, -glance, 
-keystone, -neutron, -nova and -swift (CAMEL-24961, PR #28406).

h4. 1. A producer only works on the thread that created it

Every openstack endpoint builds the {{OSClient}} once in {{createProducer()}} 
(e.g. {{NovaEndpoint}}, main 2a465aa4814c, lines 75-85, through 
{{AbstractOpenstackEndpoint.createClient}}) and keeps it in 
{{AbstractOpenstackProducer}} (line 41). The openstack4j session is per thread 
({{OSClientSession}}), so a call from any other thread fails with a 
NullPointerException "OSClientSession.getCurrent() is null" or "Unable to 
retrieve current session". A route from a file consumer to swift fails this 
way, including the example in the openstack-swift doc. All six components share 
the code. Checked on 4.24.0-SNAPSHOT with the module's in-JVM WireMock.

Proposed: keep the token and call {{OSFactory.clientFromToken(...)}} on each 
call (the openstack4j way to use a client from several threads).

h4. 2. swift and glance: the payload has no type conversion

{{AbstractOpenstackProducer.createPayload}} (lines 45-64) accepts a 
{{Payload}}, {{URL}}, {{File}} or {{InputStream}} with {{instanceof}} checks, 
so a String, byte[], {{Path}} or {{GenericFile}} body fails "You have to set 
payload. It can be InputStream, File or URL class" (swift object create, glance 
create/upload). Checked on 4.24.0-SNAPSHOT with WireMock.

Proposed: convert the body with the type converter (to InputStream) when it is 
none of these types.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to