Spring Boot Filters vs Interceptors — Most developers confuse this 🤯 Let’s simplify 👇 ✅ Filter (Servlet level) - Works BEFORE DispatcherServlet - Used for logging, authentication, request modification ✅ Interceptor (Spring level) - Works AFTER DispatcherServlet - Used for business-level checks 💡 Flow: Request → Filter → DispatcherServlet → Interceptor → Controller ⚡ Real use case: - Filter → JWT validation - Interceptor → role-based access 👉 Choosing wrong = messy architecture Know the difference = cleaner backend 🔥 #SpringBoot #Java #BackendDeveloper
Spring Boot Filters vs Interceptors Explained
More Relevant Posts
-
🚨 Spring Boot Trap @Transactional looks simple. But it has rules. It works when: • Called from another bean • Public methods • Proxy is active It fails silently when: • Self-invocation • Wrong propagation • Async methods Result? Data inconsistency. Always test transaction boundaries. Don’t assume they work. #SpringBoot #Java #Transactions #Backend #BackendDevelopment #JavaDeveloper #SoftwareEngineering #TechTips #SoftwareEngineer
To view or add a comment, sign in
-
-
Spring Boot Bean Scope — Not just Singleton 🤯 Most developers only know this: 👉 Default scope = Singleton But there’s more 👇 ✅ Prototype → New instance every time ✅ Request → Per HTTP request ✅ Session → Per user session 💡 Why it matters: ✔ Memory optimization ✔ Better state handling ⚠️ Mistake: Using singleton for stateful data ❌ 👉 Leads to concurrency issues 🔥 Real lesson: Choose scope based on use case, not default Backend bugs often start here 🚨 #SpringBoot #Java #Architecture
To view or add a comment, sign in
-
Spent 15 minutes wondering why my REST API was returning empty response The endpoint was working fine yesterday Checked the controller and service layer Everything looked correct Turns out I forgot @ResponseBody on the controller method @GetMapping("/users") public List<User> getUsers() { return userService.getAllUsers(); } Without @ResponseBody Spring tries to resolve a view instead of returning JSON Quick fix was adding @RestController instead of @Controller #Java #SpringBoot #REST #BackendDevelopment
To view or add a comment, sign in
-
Spring Boot Circular Proxy Issue — Advanced trap 🤯 Even if you FIX circular dependency… Spring may still create proxies internally. 👉 This can lead to: ❌ Unexpected behavior ❌ Method not executing correctly 💡 Why? Spring uses AOP proxies (JDK / CGLIB) ⚠️ Problem: Internal method calls bypass proxy Example: Method A → calls Method B internally 👉 AOP (like @Transactional) won’t apply 🔥 Solution: ✔ Move logic to another bean ✔ Avoid internal method calls 👉 This is why some transactions “don’t work” Understanding proxies = senior-level Spring knowledge 💯 #SpringBoot #Java #AOP
To view or add a comment, sign in
-
💡 3 things I wish I knew before my first production deployment: → Caching is not optional at scale — it's survival → A 30% query optimization can feel like buying new hardware → Logs are your best friend at 2AM when things break Backend development taught me that performance is a feature, not an afterthought. #Java #SpringBoot #BackendEngineering #LessonsLearned
To view or add a comment, sign in
-
🔍 Filters vs Interceptors in Spring Boot — and why most devs mix them up Both intercept HTTP requests. Both let you run logic before and after your controller. But they live at completely different layers — and choosing the wrong one leads to subtle bugs. Here's the mental model that clears it up: Filter = Servlet Container layer. Runs before DispatcherServlet even knows a request came in. It sees everything — including static resources. Interceptor = Spring MVC layer. Runs after DispatcherServlet, before your controller method. It knows which handler is being called. The one-line rule I use: If it needs to apply to every request, use a Filter. If it needs to know which endpoint is being called, use an Interceptor. This distinction matters for: → Security — JWT pre-checks live in Filters, role validation in Interceptors → Logging — request metadata at filter level, execution time at interceptor level → Clean architecture — putting logic at the right layer keeps things testable Swipe through the full breakdown with code examples and comparison table 👇 💬 Drop a comment: Which one do you use more in production, and for what? #SpringBoot #Java #BackendDevelopment #Microservices #SpringMVC #JavaDeveloper #SoftwareArchitecture #TechInterview #SpringFramework #Programming
To view or add a comment, sign in
-
-
Spring Boot Silent Failures — Hardest bugs to debug 😵 Sometimes your app fails… but no error ❌ Why? 👉 Exceptions swallowed internally 👉 Async methods not logging errors 👉 Improper logging config 💡 Example: @Async method throws exception 👉 You never see it 😱 Solution 👇 ✔ Use AsyncExceptionHandler ✔ Proper logging setup ✔ Enable debug logs when needed ⚠️ Biggest mistake: Ignoring logs 👉 Logs = your only truth in production Senior engineers debug logs, not code 🔥 #SpringBoot #Java #Debugging
To view or add a comment, sign in
-
Spent 10 minutes wondering why my Spring Boot application was not picking up environment variables. The code looked fine: @Value("${DATABASE_URL}") private String databaseUrl; No errors at startup. But the value was always null. The problem: I was using underscores in the property name, but Spring expects dots or lowercase with hyphens. The fix: @Value("${database.url}") private String databaseUrl; And in application_properties: database.url=${DATABASE_URL} One mapping. That was it. Spring does not automatically convert environment variable names to property names. You need to map them explicitly. What environment variable issue has caught you off guard? #Java #SpringBoot #EnvironmentVariables #Debugging #BackendDevelopment
To view or add a comment, sign in
-
Spring Boot Thread Pool Tuning — Hidden performance killer ⚠️ Most developers ignore this… and it hurts performance badly. By default: 👉 Spring Boot uses a limited thread pool If traffic increases: ❌ Requests get queued ❌ Response time increases 💡 Solution: Configure Thread Pool @Bean public TaskExecutor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(10); executor.setMaxPoolSize(50); executor.setQueueCapacity(100); executor.initialize(); return executor; } ⚡ Real impact: ✔ Better concurrency ✔ Faster request handling ✔ Stable system under load 👉 Default config is NOT enough for production Performance tuning starts here 🔥 #SpringBoot #Java #Performance
To view or add a comment, sign in
-
Devlog #12 - PulseNotify Started the user-service today. Two entities: UserAccount and UserPreference (channel specific settings per user) Flyway migration with user_svc schema and index on user_id Named the entity UserAccount instead of User to avoid future classpath if in the future I Implement Spring Security Repo: https://lnkd.in/d4rtYMAa #Java #SpringBoot #Microservices #TechJobs #BuildingInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development