@@ -240,7 +240,7 @@ protected Object interceptSync(MethodInvocationContext context, ReturnType retur
240
240
}
241
241
242
242
/**
243
- * Intercept the aync method invocation.
243
+ * Intercept the async method invocation.
244
244
*
245
245
* @param context Contains information about method invocation
246
246
* @param returnTypeObject The return type of the method in Micronaut
@@ -273,7 +273,7 @@ protected Object interceptCompletableFuture(MethodInvocationContext<Object, Obje
273
273
return ;
274
274
}
275
275
}
276
- CompletableFuture <?> completableFuture = (CompletableFuture ) context .proceed ();
276
+ CompletableFuture <?> completableFuture = (CompletableFuture <?> ) context .proceed ();
277
277
if (completableFuture == null ) {
278
278
thisFuture .complete (null );
279
279
} else {
@@ -290,8 +290,14 @@ protected Object interceptCompletableFuture(MethodInvocationContext<Object, Obje
290
290
}
291
291
};
292
292
if (o1 != null ) {
293
+ if (LOG .isTraceEnabled ()) {
294
+ LOG .trace ("Storing in the cache [{}] with key [{}] the result of invocation [{}]: {}" , asyncCache .getName (), key , context , o1 );
295
+ }
293
296
asyncCache .put (key , o1 ).whenComplete (completionHandler );
294
297
} else {
298
+ if (LOG .isTraceEnabled ()) {
299
+ LOG .trace ("Invalidating the key [{}] of the cache [{}] since the result of invocation [{}] was null" , key , asyncCache .getName (), context );
300
+ }
295
301
asyncCache .invalidate (key ).whenComplete (completionHandler );
296
302
}
297
303
@@ -376,6 +382,9 @@ private Publisher<Object> buildCacheInvalidatePublisher(
376
382
if (invalidateAll ) {
377
383
for (String cacheName : cacheNames ) {
378
384
AsyncCache <?> asyncCache = cacheManager .getCache (cacheName ).async ();
385
+ if (LOG .isTraceEnabled ()) {
386
+ LOG .trace ("Invalidating all the entries of the cache [{}]" , asyncCache .getName ());
387
+ }
379
388
asyncCache .invalidateAll ().whenCompleteAsync ((aBoolean , throwable ) -> {
380
389
if (throwable != null ) {
381
390
asyncCacheErrorHandler .handleInvalidateError (asyncCache , asRuntimeException (throwable ));
@@ -389,6 +398,9 @@ private Publisher<Object> buildCacheInvalidatePublisher(
389
398
Object key = keyGenerator .generateKey (context , parameterValues );
390
399
for (String cacheName : cacheNames ) {
391
400
AsyncCache <?> asyncCache = cacheManager .getCache (cacheName ).async ();
401
+ if (LOG .isTraceEnabled ()) {
402
+ LOG .trace ("Invalidating the key [{}] of the cache [{}]" , key , asyncCache .getName ());
403
+ }
392
404
asyncCache .invalidate (key ).whenCompleteAsync ((aBoolean , throwable ) -> {
393
405
if (throwable != null ) {
394
406
asyncCacheErrorHandler .handleInvalidateError (asyncCache , asRuntimeException (throwable ));
@@ -538,8 +550,14 @@ private Publisher<Object> buildCacheablePublisher(
538
550
}
539
551
};
540
552
if (o != null ) {
553
+ if (LOG .isTraceEnabled ()) {
554
+ LOG .trace ("Storing in the cache [{}] with key [{}] the result of invocation [{}]: {}" , asyncCache .getName (), key , context , o );
555
+ }
541
556
asyncCache .put (key , o ).whenComplete (completionHandler );
542
557
} else {
558
+ if (LOG .isTraceEnabled ()) {
559
+ LOG .trace ("Invalidating the key [{}] of the cache [{}] since the result of invocation [{}] was null" , key , asyncCache .getName (), context );
560
+ }
543
561
asyncCache .invalidate (key ).whenComplete (completionHandler );
544
562
}
545
563
}).toFlowable ();
@@ -787,6 +805,9 @@ private void processCacheEvict(
787
805
if (async ) {
788
806
AsyncCache <?> asyncCache = syncCache .async ();
789
807
if (invalidateAll ) {
808
+ if (LOG .isTraceEnabled ()) {
809
+ LOG .trace ("Invalidating all the entries of the cache [{}]" , asyncCache .getName ());
810
+ }
790
811
CompletableFuture <Boolean > future = asyncCache .invalidateAll ();
791
812
future .whenCompleteAsync ((aBoolean , throwable ) -> {
792
813
if (throwable != null ) {
@@ -795,6 +816,9 @@ private void processCacheEvict(
795
816
}, ioExecutor );
796
817
} else {
797
818
Object finalKey = key ;
819
+ if (LOG .isTraceEnabled ()) {
820
+ LOG .trace ("Invalidating the key [{}] of the cache [{}]" , key , asyncCache .getName ());
821
+ }
798
822
CompletableFuture <Boolean > future = asyncCache .invalidate (key );
799
823
future .whenCompleteAsync ((aBoolean , throwable ) -> {
800
824
if (throwable != null ) {
@@ -805,6 +829,9 @@ private void processCacheEvict(
805
829
} else {
806
830
if (invalidateAll ) {
807
831
try {
832
+ if (LOG .isTraceEnabled ()) {
833
+ LOG .trace ("Invalidating all the entries of the cache [{}]" , syncCache .getName ());
834
+ }
808
835
syncCache .invalidateAll ();
809
836
} catch (RuntimeException e ) {
810
837
if (errorHandler .handleInvalidateError (syncCache , e )) {
@@ -813,6 +840,9 @@ private void processCacheEvict(
813
840
}
814
841
} else {
815
842
try {
843
+ if (LOG .isTraceEnabled ()) {
844
+ LOG .trace ("Invalidating the key [{}] of the cache [{}]" , key , syncCache .getName ());
845
+ }
816
846
syncCache .invalidate (key );
817
847
} catch (RuntimeException e ) {
818
848
if (errorHandler .handleInvalidateError (syncCache , key , e )) {
0 commit comments