We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f1aff6 commit 8d1bf99Copy full SHA for 8d1bf99
handler-loader/src/main/java/fr/axelop/agnosticserverlessfunctions/HandlerLoader.java
@@ -6,13 +6,15 @@
6
public class HandlerLoader {
7
8
private static final Class<Handler> HANDLER_CLASS = Handler.class;
9
+ private static Optional<Handler> cached = Optional.empty();
10
11
public Handler loadOrThrow() throws HandlerNotFoundException {
12
return load().orElseThrow(HandlerNotFoundException::new);
13
}
14
15
public Optional<Handler> load() {
- return ServiceLoader.load(HANDLER_CLASS).findFirst();
16
+ cached = cached.or(ServiceLoader.load(HANDLER_CLASS)::findFirst);
17
+ return cached;
18
19
20
0 commit comments