Skip to content

Commit c095cf5

Browse files
committed
docs: Add SnapStart priming subsection for validation
1 parent 4e97c65 commit c095cf5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/utilities/validation.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,31 @@ If you need to configure the Jackson ObjectMapper, you can use the `ValidationCo
292292
}
293293
}
294294
```
295+
296+
## Advanced
297+
298+
### SnapStart priming
299+
To enable priming with AWS Lambda SnapStart, you need an explicit reference to `ValidationConfig` to allow the library to register before SnapStart takes a memory snapshot.
300+
301+
The `@Validation` annotation uses AspectJ compile-time weaving, which means there may be no runtime reference that triggers `ValidationConfig` to load during the INIT phase.
302+
Hence without explicit reference, the priming logic will not execute.
303+
304+
So to ensure `ValidationConfig` is loaded, you need to add an explicit reference in your handler class. This can be done by adding one of the following to your handler class:
305+
306+
=== "Constructor"
307+
308+
```java hl_lines="3"
309+
...
310+
public MyHandler() {
311+
ValidationConfig.get(); // Ensure ValidationConfig is loaded for SnapStart
312+
}
313+
```
314+
315+
=== "Static Initializer"
316+
317+
```java hl_lines="3"
318+
...
319+
static {
320+
ValidationConfig.get(); // Ensure ValidationConfig is loaded for SnapStart
321+
}
322+
```

0 commit comments

Comments
 (0)