API / Apache Velocity Interview questions
Why doesn't Velocity throw an exception by default for an undefined reference?
Velocity ships with "lenient" reference resolution as its default behavior: if a template references a variable that was never added to the context, or calls a method/property that returns null, Velocity simply prints the reference's literal text (like $missingVar) instead of raising an error and aborting the render.
This choice favors availability over strictness. It means a small typo or a template referencing a field that a particular code path forgot to populate won't take down the entire page, which mattered a lot for early Velocity use cases like generating large batches of emails where one bad record shouldn't halt the whole run.
The trade-off is that these mistakes are easy to miss visually and can leak literal $reference text into production output. That's exactly why Velocity later added an opt-in strict reference mode for teams who prefer to fail fast during development.
More Related questions...