@@ -6,6 +6,42 @@ implementation, see the Javadoc of `waffle.util.cache.Cache#newCache`…also sho
6
6
7
7
``` javadoc
8
8
* The cache implementation is obtained using {@link ServiceLoader}. To create your own implementation, implement
9
- * {@link CacheSupplier} and register it using the {@code /META-INF/services/waffle.cache.CacheSupplier} file on
10
- * your classpath.
9
+ * {@link CacheSupplier} and register it using the {@code /META-INF/services/waffle.util.cache.CacheSupplier} file
10
+ * on your classpath.
11
+ ```
12
+
13
+ ### Error message (in log file)
14
+ `No CacheSupplier implementation found by ServiceLoader. Please see
15
+ https://github.com/Waffle/waffle/blob/master/Docs/faq/CustomCache.md for possible solutions. Falling back to default
16
+ CaffeineCache implementation.`
17
+
18
+ #### Solutions
19
+ See the primary answer above for specifying a custom cache, or even just re-specifying the default load of
20
+ ` waffle.util.cache.CaffeineCacheSupplier ` , by using the ` META-INF/services/waffle.util.cache.CacheSupplier ` file on
21
+ your classpath.
22
+
23
+ If you are still getting the message after trying that (most likely in use cases where you don't have much control
24
+ over the application classpath, like in a plugin environment), then you may need to adapt the thread
25
+ ContextClassLoader prior to the call in your code that leads to the error message, like in the below example. Note
26
+ that this is a workaround for when providing the file mentioned above in your classpath just doesn't work.
27
+
28
+ ``` java
29
+ // Save the current ContextClassLoader
30
+ Thread thread = Thread . currentThread();
31
+ ClassLoader loader = thread. getContextClassLoader();
32
+
33
+ // Set the desired ContextClassLoader
34
+ // In this case, using CacheSupplier to use the default CacheSupplier specified by the waffle-jna package
35
+ // You may choose a different class in the waffle-jna package
36
+ // You will want to choose a class in your classpath if you use the
37
+ // META-INF/services/waffle.util.cache.CacheSupplier file to provide a custom cache implementation
38
+ thread. setContextClassLoader(CacheSupplier . class. getClassLoader());
39
+
40
+ // Call Waffle-jna code that produced the error
41
+ // example:
42
+ try {
43
+ this . negotiateSecurityFilter. init();
44
+ } finally {
45
+ thread. setContextClassLoader(loader);
46
+ }
11
47
```
0 commit comments