Why this matters
Prevents resource leaks of streams/sockets and simplifies finally blocks.
Use try-with-resources for Closeable/AutoCloseable objects to guarantee deterministic cleanup.
Prevents resource leaks of streams/sockets and simplifies finally blocks.
Side-by-side examples engineers can pattern-match during review.
BufferedReader br = new BufferedReader(new FileReader(p));
String s = br.readLine(); // no closetry (BufferedReader br = new BufferedReader(new FileReader(p))) {
String s = br.readLine();
}new FileInputStream(p)try (InputStream in = new FileInputStream(p)) { /* ... */ }From the same buckets as this rule.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.