Skip to main content

Posts

Showing posts with the label Real World Issues

๐Ÿ” "Billing Gone Wrong: How Lack of Synchronization Led to Swapped Bills (And What I Learned!)"

☕ A Walk Down Memory Lane: My First Bug Nightmare About 9 years ago, as a fresher, I worked on a billing system for a retail application. The system was accessed both from mobile and web UI , and the actual billing logic was written in stored procedures (SQL-based backend). Everything looked fine... until customers started reporting weird issues : ๐Ÿ› The Bug: Bills Were Swapping Items! ๐Ÿ˜ฑ ๐Ÿงพ Scenario: Two different users generated separate bills around the same time One from Mobile , the other from Web The output bills had mixed-up items — each invoice had products that belonged to the other one! ๐Ÿงจ ๐Ÿ” Initial Questions: "Is this a DB issue?" "Are stored procedures broken?" "Race condition in app layer?" Turns out... ๐Ÿšซ The code calling stored procedures wasn’t thread-safe. There was no synchronized mechanism to ensure each bill transaction was isolated. ๐Ÿง  The Root Cause Analysis (RCA): We were calling a shared BillingService.calculat...

๐Ÿš€ Demystifying JUnit Testing with Mockito & Spring Extensions

๐Ÿ‘‹ Before diving deep into testing, I always assumed: "JUnit is just something you use with @Test… it just works!"   But once I actually started exploring test frameworks in real-world projects, I realized there's so much more behind the scenes. So here’s a blog to clarify the confusion , make it visually digestible , and hopefully save you some debugging hours . Let’s roll! ๐Ÿง ✨ ๐Ÿ” Step 1: What dependencies should I include for JUnit? You may have seen these terms in your build.gradle : testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' implementation 'com.example:some-library:1.2.3' But wait... what’s the difference? ๐Ÿค” ✅ implementation This means: Include the library for both compile time AND runtime . It will be packaged inside the final JAR/WAR. Use it for things your production code needs. ๐Ÿงช testImplementation This means: Use it only during test execution . It will NOT be added to the production JAR/WAR. Perfect for JU...