Skip to content

Commit 46426c3

Browse files
committed
Fix to sdc_1944 to handle null SecurityContext. (#1981)
Closes #1944.
1 parent d75b4b6 commit 46426c3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/springframework/data/couchbase/transaction/CouchbaseCallbackTransactionManager.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public boolean isCompleted() {
179179
};
180180

181181
// Get caller's resources, set SecurityContext for the transaction
182-
return CouchbaseResourceOwner.get().map(cbrh -> setSecurityContext(cbrh.get().getSecurityContext()))
182+
return CouchbaseResourceOwner.get().map(cbrh -> cbrh.map( c -> setSecurityContext(c.getSecurityContext())))
183183
.flatMap(ignore -> Flux.from(callback.doInTransaction(status)).doOnNext(v -> out.add(v))
184184
.then(Mono.defer(() -> {
185185
if (status.isRollbackOnly()) {
@@ -304,7 +304,8 @@ static private Object getSecurityContext() {
304304
.forName("org.springframework.security.core.context.SecurityContextHolder");
305305
return securityContextHolderClass.getMethod("getContext").invoke(null);
306306
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException
307-
| InvocationTargetException cnfe) {}
307+
| InvocationTargetException cnfe) {
308+
}
308309
return null;
309310
}
310311

0 commit comments

Comments
 (0)