davsclaus commented on code in PR #29109:
URL: https://github.com/apache/camel/pull/29109#discussion_r4466103283
##########
components/camel-openstack/src/main/java/org/apache/camel/component/openstack/common/AbstractOpenstackProducer.java:
##########
@@ -26,20 +26,58 @@
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StringHelper;
import org.openstack4j.api.OSClient;
+import org.openstack4j.api.OSClient.OSClientV2;
+import org.openstack4j.api.OSClient.OSClientV3;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.common.Payload;
import org.openstack4j.model.common.Payloads;
+import org.openstack4j.openstack.OSFactory;
public abstract class AbstractOpenstackProducer extends DefaultProducer {
protected OSClient os;
- private AbstractOpenstackEndpoint endpoint;
+ private final AbstractOpenstackEndpoint endpoint;
+
+ // the session with the newest token, as openstack4j re-authenticates an
expired token into the session in use
+ private volatile OSClient session;
protected AbstractOpenstackProducer(AbstractOpenstackEndpoint endpoint,
OSClient client) {
super(endpoint);
this.os = client;
this.endpoint = endpoint;
+ this.session = client;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ final OSClient current = useSession();
+ try {
+ doProcess(exchange);
+ } finally {
+ session = current;
Review Comment:
Checked against the openstack4j 3.12 sources: it updates the session in
place, so `session = current` keeps the renewed token.
- On a 401, `HttpExecutorServiceImpl.invokeRequest` (okhttp connector) calls
`OSAuthenticator.reAuthenticate()`, then reads the new token from
`OSClientSession.getCurrent()`.
- `reAuthenticate()` builds its `SessionInfo` with
`reLinkToExistingSession=true`, so `authenticateV3` sets `current.token =
token` on the session of the thread (`authenticateV2` sets `current.access`)
and does not create a new one.
- `current` is that thread's session: `OSFactory.clientFromToken` /
`clientFromAccess` create it with `createSession`, whose constructor calls
`sessions.set(this)`.
So no change is needed.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]