简体   繁体   中英

Sonarlint Violations for Guava Suppliers used with Memoize

I am using Guava Suppliers to memoize and reload some data after fixed time some in my class. Recently sonarlint started generating warning with message such as 'Java 8 features should be preferred to Guava (squid:S4738)'.

Can anyone tell me i can actually use Java Supplier here in any way to achieve the same functionality?

Code Sample

private final Supplier<Set<Integer>> cache = Suppliers.memoizewithExpiration(fetchData(), 1, TimeUnit.DAYS);

Use import java.util.function.Supplier instead of com.google.common.base.Supplier .

Guava's Supplier extends Java's Supplier so it's safe to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM