Introduction to Lock Striping
1. Introduction In this tutorial, we're going to learn how to achieve fine-grained synchronization, also known as Lock Striping, a pattern for handling concurrent access to data structures while...
View ArticleJava Convert PDF to Base64
1. Overview In this short tutorial, we'll see how to do Base64 encoding and decoding of a PDF file using Java 8 and Apache Commons Codec. But first, let's take a quick peek at the basics of Base64. 2....
View ArticleGuide to AtomicMarkableReference
1. Overview In this tutorial, we'll dive into the details of the AtomicMarkableReference class from the java.util.concurrent.atomic package. Next, we'll walk through the API methods of the class, and...
View ArticleGradient Descent in Java
1. Introduction In this tutorial, we'll learn about the Gradient Descent algorithm. We'll implement the algorithm in Java and illustrate it step by step. 2. What Is Gradient Descent? Gradient Descent...
View ArticleBoruvka’s Algorithm for Minimum Spanning Trees
1. Overview In this tutorial, we'll take a look at the Java implementation of Boruvka's algorithm for finding a Minimum Spanning Tree (MST) of an edge-weighted graph. It predates Prim's and Kruskal's...
View ArticleSpring JdbcTemplate Unit Testing
1. Overview Spring JdbcTemplate is a powerful tool for developers to focus on writing SQL queries and extracting results. It connects to the back-end database and executes SQL queries directly....
View ArticleRegular Expressions \s and \s+ in Java
1. Overview String substitution is a standard operation when we process strings in Java. Thanks to the handy replaceAll() method in the String class, we can easily do string substitution with regular...
View ArticleQuick Guide to EntityManager#getReference()
1. Introduction The getReference() method of the EntityManager class has been a part of the JPA specification since the first version. However, this method confuses some developers because its behavior...
View ArticleJava Weekly, Issue 326
1. Spring and Java >> Getting Started With RSocket: Spring Boot Request-Stream [spring.io] A quick example of client-side and server-side data streaming with the RSocket protocol. >> Your...
View ArticleJava ArrayList vs LinkedList
1. Overview When it comes to collections, the Java standard library provides plenty of options to choose from. Among those options are two famous List implementations known as ArrayList and LinkedList,...
View ArticlePrevent ApplicationRunner or CommandLineRunner Beans From Executing During...
1. Overview In this tutorial, we'll show how we can prevent beans of type of ApplicationRunner or CommandLineRunner from running during Spring Boot integration tests. 2. Example Application Our example...
View ArticleFixing “constant string too long” Build Error
1. Overview When we try to use a variable that is too long for the Java compiler (larger than 64 KB) we receive a “constant string too long” error from the compiler. In this tutorial, we're going to...
View ArticleThe Clear-Site-Data Header in Spring Security
1. Overview For network optimization, some websites allow browsers to cache resources like CSS or JS in local storage. This allows browsers to save a network round trip for every request. So caching...
View ArticleTesting Multi-Threaded Code in Java
1. Introduction In this tutorial, we'll cover some of the basics of testing a concurrent program. We'll primarily focus on thread-based concurrency and the problems it presents in testing. We'll also...
View ArticleComparing Long Values in Java
1. Overview In this short tutorial, we'll discuss different ways to compare two Long instances. We emphasize the problems that arise when using the reference comparison operator (==). 2. Problem Using...
View ArticleKotlin Reactive Microservice With Spring Boot
1. Overview In this tutorial, we’re going to develop a reactive microservice application with Kotlin and Spring Boot. Our application will expose a REST API, persist data in a database and have...
View ArticleHow to determine day of week by passing specific date in Java?
1. Overview In this short tutorial, we'll see how to extract the day of the week as a number and as text from a Java date. 2. Problem Business logic often needs the day of the week. Why? For one,...
View ArticleDifference Between BeanFactory and ApplicationContext
1. Overview The Spring Framework comes with two IOC containers – BeanFactory and ApplicationContext. The BeanFactory is the most basic version of IOC containers, and the ApplicationContext extends the...
View ArticleJava Weekly, Issue 327
1. Spring and Java >> Liveness and Readiness Probes with Spring Boot [spring.io] Additional support for managing Kubernetes application and container lifecycle is coming to Spring Boot 2.3....
View ArticleAdd CSS and JS to Thymeleaf
1. Introduction In this quick tutorial, we're going to learn how to use CSS and JavaScript in our Thymeleaf templates. First, we'll go over the expected folder structure so we know where to put our...
View Article