Skip to main content

Posts

#9/10 | Spring Boot + Docker Compose: 7 Bugs That Broke My First Boot

Part 9 of 10 of Building Instagram's Authentication Backend . If you're just joining, the repo is here and you can catch the earlier parts on the YouTube playlist . Eight parts of code, zero runs By the end of part 8, every layer of this backend existed: DTOs, exceptions, entities, repositories, five services, a security filter chain and a controller. And I had never started the application. Not once. Everything so far was code I'd reasoned through and believed would work. This part is where that belief gets tested. We containerize the app, put Postgres, Redis and a fake mail server next to it, and bring all four up with one command. It did not work the first time, so this post is the real debugging session, with each bug, its symptom and its fix. If you're containerizing your own Spring Boot app, there's a good chance you'll hit at least one of these. In this post: A multi-stage Dockerfile for Spring Boot, line by line A docker-compose.yml ...

Java Streams Explained: Intermediate, Terminal, Lazy & Java 9+

Java Streams Explained Clearly (Java 8–21): Intermediate, Terminal, Lazy Execution, Stateless vs Stateful, and  takeWhile()  /  dropWhile() Java Streams are one of the most important features introduced in  Java 8 , and they are now used heavily in  real-world backend projects  and  Java interviews . In this article, you will learn  Java Streams from the ground up , including: What Java Streams are and why they exist Intermediate vs Terminal operations Why streams are lazy Stateless vs Stateful operations (very important) takeWhile()  and  dropWhile()  explained in detail (Java 9+) Performance and parallel streams Common mistakes and interview questions This guide is written in  simple language , with  clear examples , and is suitable for  beginners, working professionals, and interview preparation . What Are Java Streams and Why Were They Introduced? Before Java 8, most data processing in Java was done using  lo...

Python Developer Roadmap (2026): From Beginner to Job-Ready

Python Developer Roadmap (2026): From Beginner to Job-Ready Python has evolved from a simple scripting language into one of the  most versatile and in-demand programming languages  in the world. In 2026, Python is widely used for  backend development, automation, data-driven applications, and interviews across startups and large companies . If you are confused about  where to start ,  what to learn next , and  how to prepare for jobs , this Python developer roadmap will give you a  clear, structured path  from beginner to job-ready Python developer. This roadmap is intentionally balanced: Beginner-friendly Backend-oriented Interview-focused Who Should Follow This Python Developer Roadmap? This roadmap is ideal for: Complete beginners starting their programming journey Java or other language developers switching to Python Backend developers expanding their skill set Professionals preparing for Python interviews Students aiming for software developm...

Java ConcurrentHashMap vs CopyOnWriteArrayList: CAS, Contention, Retries & Iterators Explained

Introduction Most modern Java applications are  multi-threaded  — whether you are building: Web applications Microservices Background workers Scheduled jobs When multiple threads access  shared data , things can easily go wrong. This article explains — in  simple, beginner-friendly language  — how Java solves concurrency problems using: ConcurrentHashMap CopyOnWriteArrayList CAS (Compare-And-Swap) Low vs High contention Retries Iterator behavior Java version changes (Java 7 vs Java 8+) This guide is useful for: Java backend developers Interview preparation Anyone confused by Java concurrency Why Thread Safety Matters in Java A  race condition  happens when: Multiple threads read and write shared data Execution order becomes unpredictable Data becomes inconsistent Example problems: Lost updates Incorrect counters Random production bugs This is why  thread safety is critical  in Java. Why HashMap and ArrayList Are Not Thread-Safe Collections li...

Java Collections Deep Dive

Introduction In real Java applications, we rarely work with just one value. Most of the time, we deal with: A list of users A set of permissions A map of IDs and objects A queue of tasks Handling such data using normal variables is not possible. This is where  Java Collections  come into the picture. Java Collections are ready-made data structures provided by Java to store, manage, and process multiple objects easily and efficiently. Understanding Java Collections is extremely important for: Backend development Real-world applications Java interviews Before starting interview preparation, it’s important to follow a structured  Java backend developer roadmap  so you don’t miss core fundamentals. Java Backend Developer Roadmap 2026 Why Java Collections Are Needed Before Java Collections, developers used  arrays . Arrays have multiple problems: Fixed size (cannot grow or shrink) No built-in methods for sorting or searching Difficult to manage large and dynamic data...

Java HashMap Internals Explained in Simple Terms

Java  HashMap  is one of the most frequently asked topics in Java interviews. Many developers use it daily, but very few understand  how it actually works internally . In this article, we will explain: What HashMap is How HashMap stores data internally Role of  hashCode()  and  equals() What collisions are and how they are handled Improvements made in newer Java versions Time complexity of all major operations How to reduce frequent collisions All explanations are in  simple terms , with  examples . 1. What Is a HashMap? A  HashMap  stores data in  key–value pairs . Example: Map<String, Integer> map = new HashMap<>(); map.put("A", 10); map.put("B", 20); Key characteristics: Keys must be  unique Values can be duplicated Order is  not guaranteed One  null key  is allowed Multiple null values are allowed Why HashMap is popular: HashMap provides very fast access to data. 2. How HashMap Stores Data Interna...

Why HashMap Uses (n - 1) & hash and Why Capacity Is Always Power of 2

If you are learning  Java HashMap internals , one line that often confuses beginners is: index = (n - 1) & hash; Many people ask: Where is the  power of 2  here? Why not use  %  (modulo)? Why does HashMap care so much about powers of 2? In this article, we’ll explain everything in  very simple terms . What Is  n  in  (n - 1) & hash ? In this formula: index = (n - 1) & hash; n  is the  capacity of the HashMap , meaning the  number of buckets . Important rule: HashMap capacity is ALWAYS a power of 2 Examples: 16 → 2⁴ 32 → 2⁵ 64 → 2⁶ 128 → 2⁷ So the  power of 2 is hidden inside  n . Why HashMap Capacity Must Be Power of 2 HashMap calculates bucket index using  bitwise AND ( & ) , not modulo ( % ). This works correctly  only when  n  is a power of 2 . Let’s understand this with an example. Example: Capacity = 16 (Power of 2) Binary values: n = 16 → 10000 n - 1 = 15 → 01111 Now sup...

Top Backend Anti-Patterns That Kill Scalability

Scalability issues usually do not appear on day one. Most backend systems work perfectly fine with low traffic. The problems start  when users increase and data grows . In many cases, the system fails not because of traffic, but because of  bad backend design decisions made early . These decisions are called  anti-patterns . In this article, we will cover the  most common backend anti-patterns  that silently break scalability, explained in simple language with clear reasoning. Before starting interview preparation, it’s important to follow a structured  Java backend developer roadmap  so you don’t miss core fundamentals. Java Backend Developer Roadmap 2026 1. Turning Microservices Into a Distributed Monolith What Goes Wrong Teams break a monolithic application into multiple services and call it “microservices”. However: All services share the same database Services cannot be deployed independently One service failure affects others This is not real mic...