Performance: @GetMapping for GET requests
MEDIUM IMPACT
This affects server response time and client perceived loading speed by handling HTTP GET requests efficiently.
@GetMapping("/data") public CompletableFuture<String> getData() { return CompletableFuture.supplyAsync(() -> { // Simulate async processing try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } return "Data"; }); }
@GetMapping("/data") public String getData() { // Heavy synchronous processing try { Thread.sleep(5000); // Simulate delay } catch (InterruptedException e) { e.printStackTrace(); } return "Data"; }
| Pattern | Server Thread Usage | Response Delay | Impact on LCP | Verdict |
|---|---|---|---|---|
| Synchronous blocking @GetMapping | Blocks thread during processing | High delay (e.g., 5s) | Increases LCP significantly | [X] Bad |
| Asynchronous @GetMapping with CompletableFuture | Non-blocking, frees threads | Response delayed but server handles concurrency better | Improves LCP under load | [OK] Good |