In the bustling world of multi-user applications, ensuring data integrity becomes paramount. When multiple users contend for the same resource, conflicts can arise, leading to lost updates and unintended side effects. Here’s where pessimistic locking steps in, acting as a valiant knight guarding data consistency in Spring Boot applications. What is Pessimistic Locking? Imagine two…
In the world of Java development, Spring Boot has emerged as a game-changer. This revolutionary framework provides a streamlined way to build production-ready applications. With its minimalist approach and a plethora of built-in features, Spring Boot has become the go-to choice for developers seeking rapid application development. The Spring Boot Advantage Convention over Configuration…
[web_stories title=”true” excerpt=”false” author=”false” date=”false” archive_link=”true” archive_link_label=”” circle_size=”150″ sharp_corners=”false” image_alignment=”left” number_of_columns=”1″ number_of_stories=”5″ order=”DESC” orderby=”post_title” view=”circles” /] In this post, we will showcase a step-by-step guide on how to detect and present distinctions between two java objects by leveraging a set of classes and interfaces provided by Apache Commons Lang. Classes, Interfaces, and pom.xml The classes…
@PropertySource and @PropertySources Annotations In Spring Framework, the @PropertySource annotation is used to specify the source of external property files that contain key-value pairs. These properties can be injected into Spring beans using the @Value annotation or by using the Environment object. Here’s an example of how to use @PropertySource in a Spring application: Create…
Intro Dates in programming are hard. The ISO-8601 Date standard made them easier, but to be entirely honest I’m not ISO-8601 Certified, so I’m not very good at my job. What I do know though is the very important difference between YYYY and yyyy when formatting dates. The Difference between yyyy and YYYY According to the DateTimeFormatter Java…
In this mockito tutorial, learn the fundamentals of the mockito framework, and how to write JUnit tests along with mockito with an example. 1. Mockito Introduction Mockito is an open-source framework that allows us to easily create test doubles (mocks). A ‘test double‘ is a generic term for any case where we replace a production object for testing…
Learn to cancel a task submitted to an executor service if the task still has to be executed and/or has not been completed yet. We can use the cancel() method of Future object that allows making the cancellation requests. 1. Future cancel() API The Future.cancel() method takes one argument of type boolean. boolean cancel(boolean mayInterruptIfRunning); Depending on the value of mayInterruptIfRunning and the status of the task submitted…
Learn to use ExecutorService.invokeAny(tasks) method where we execute multiple tasks at the same time, but we make a decision when any one of those tasks is completed and return its result. 1. invokeAny() method This method executes the given list of tasks, returning the result of one that has completed successfully (i.e., without throwing an exception),…