Fix to sdc_1944 to handle null SecurityContext. (#1981)

Closes #1944.
This commit is contained in:
Michael Reiche
2024-10-09 18:25:21 -07:00
committed by mikereiche
parent d75b4b665f
commit 46426c3d54

View File

@@ -179,7 +179,7 @@ public class CouchbaseCallbackTransactionManager implements CallbackPreferringPl
};
// Get caller's resources, set SecurityContext for the transaction
return CouchbaseResourceOwner.get().map(cbrh -> setSecurityContext(cbrh.get().getSecurityContext()))
return CouchbaseResourceOwner.get().map(cbrh -> cbrh.map( c -> setSecurityContext(c.getSecurityContext())))
.flatMap(ignore -> Flux.from(callback.doInTransaction(status)).doOnNext(v -> out.add(v))
.then(Mono.defer(() -> {
if (status.isRollbackOnly()) {
@@ -304,7 +304,8 @@ public class CouchbaseCallbackTransactionManager implements CallbackPreferringPl
.forName("org.springframework.security.core.context.SecurityContextHolder");
return securityContextHolderClass.getMethod("getContext").invoke(null);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException
| InvocationTargetException cnfe) {}
| InvocationTargetException cnfe) {
}
return null;
}