Expected Behaviour
ClassPreLoader.preloadClasses() loads every class listed in a module's classesloaded.txt during the SnapStart beforeCheckpoint phase, so those classes are baked into the snapshot and restore time drops.
Current Behaviour
ClassPreLoader loads 0 classes from powertools-tracing, because every line in its classesloaded.txt starts with a leading space. The parser calls line.stripTrailing(), which removes trailing whitespace but keeps the leading space. Class.forName(" java.lang.Object", ...) then throws ClassNotFoundException, and the loader silently swallows it for all 5996 entries. The priming hook runs but primes nothing.
powertools-tracing ships this format today, so its automatic priming is a no-op in released versions. powertools-large-messages (PR #2533) uses the same format. The other modules (kafka, lambda-metadata, metrics, validation) have no leading space and are unaffected.
Code snippet
// ClassPreLoader.preloadClassesFromStream
final String className = line.stripTrailing(); // keeps the leading space
if (!className.isBlank()) {
loadClassIfFound(className); // Class.forName(" java.lang.Object") -> ClassNotFoundException
}
Possible Solution
Replace line.stripTrailing() with line.strip() so leading whitespace is removed as well. strip() tolerates both file formats, so no resource files need to change. I verified the fix on a deployed function: loaded classes went from 0 to 4062.
Steps to Reproduce
- Deploy a Lambda that uses
powertools-tracing with SnapStart enabled (ApplyOn: PublishedVersions), and reference TracingUtils during INIT so the priming hook runs.
- Add a temporary debug log in
ClassPreLoader reporting how many classes loaded.
- Observe that 0 classes load, because every
classesloaded.txt entry carries a leading space.
Powertools for AWS Lambda (Java) version
latest
AWS Lambda function runtime
Java 11
Debugging logs
SnapStart priming: starting class preloading from 'classesloaded.txt'
SnapStart priming: successfully loaded 0 class(es) from resource
Expected Behaviour
ClassPreLoader.preloadClasses()loads every class listed in a module'sclassesloaded.txtduring the SnapStartbeforeCheckpointphase, so those classes are baked into the snapshot and restore time drops.Current Behaviour
ClassPreLoaderloads 0 classes frompowertools-tracing, because every line in itsclassesloaded.txtstarts with a leading space. The parser callsline.stripTrailing(), which removes trailing whitespace but keeps the leading space.Class.forName(" java.lang.Object", ...)then throwsClassNotFoundException, and the loader silently swallows it for all 5996 entries. The priming hook runs but primes nothing.powertools-tracingships this format today, so its automatic priming is a no-op in released versions.powertools-large-messages(PR #2533) uses the same format. The other modules (kafka, lambda-metadata, metrics, validation) have no leading space and are unaffected.Code snippet
Possible Solution
Replace
line.stripTrailing()withline.strip()so leading whitespace is removed as well.strip()tolerates both file formats, so no resource files need to change. I verified the fix on a deployed function: loaded classes went from 0 to 4062.Steps to Reproduce
powertools-tracingwith SnapStart enabled (ApplyOn: PublishedVersions), and referenceTracingUtilsduring INIT so the priming hook runs.ClassPreLoaderreporting how many classes loaded.classesloaded.txtentry carries a leading space.Powertools for AWS Lambda (Java) version
latest
AWS Lambda function runtime
Java 11
Debugging logs