Mr.Humorous 🥘

Nothing is impossible, the word itself says 'I'm possible'❗️ 💪

JUnit - Different ways to run tests using JUnitCore

Understanding JUnitCore

JUnitCore class is very useful to run tests from command line or programmatically. Using JUnitCore#run(Class<?>… classes) method public Result run(Class<?>... classes) public class Tes...

What is Spring Security Principal?

Understanding Spring Security Principal/User

The principal is the currently logged in user. However, you retrieve it through the security context which is bound to the current thread and as such it’s also bound to the current request and its ...

Spring Security Context Propagation with @Async

Understanding Spring Security Context Propagation

1. Introduction We are going to focus on the propagation of the Spring Security principal with @Async. Full example code is on Github. By default, the Spring Security Authentication is bound to a ...

Scope of a Spring-Controller and its instance-variables

Understanding Spring controller scope and its instace variables sharing

Spring MVC controllers are singletons by default. An object field will be shared and visible for all requests and all sessions forever. However without any synchronization you might run into all s...

Iterable to Stream in Java

Example of StreamSupport

1. Converting Iterable to Stream The Iterable interface is designed keeping generality in mind and does not provide any stream() method on its own. Simply put, you can pass it to StreamSupport.str...

How Spring MVC handles multiple users

Understanding Spring bean scopes

1. Problem Statement I have a spring web app. Now I autowired the model in controller. Based on url matching it calls respective method. all my methods are singleton. Now when two users are openin...

JUnit - Understanding how RunWith works

Understanding RunWith

1. Overview If a JUnit class or its parent class is annotated with @RunWith, JUnit framework invokes the specified class as a test runner instead of running the default runner. @RunWith has only o...

How are threads allocated to handle servlet request?

Understanding servlet request threads

Per request means when an HTTP request is made, a thread is created or retrieved from a pool to serve it. One thread serves the whole request. Thread per connection would be the same thing except t...

Introduction to Spring Method Security

Understanding Spring Security

1. Introduction Simply put, Spring Security supports authorization semantics at the method level. Typically, we could secure our service layer by, for example, restricting which roles are able to ...

How to deal with software erosion?

Understanding software erosion

1. What is Software Erosion? - Explained by Adam Wiggins In 2006, I wrote Catapult: a Quicksilver-inspired command-line for the web. I deployed it to a VPS (Slicehost), then gave the URL out to a ...