Home » Java » Core Java

Core Java

Java Math pow() method Example (Recursive and Loop Iterative)

A quick guide to Math.pow() method in java. Custom implementation of Math pow() using iterative and recursive approaches. 1. Overview In this post, You will learn how to calculate the power of a number using the Math pow() method in java.  In other words, in Some interviews, these questions are asked as writing a program to find/calculate the power of ...

Read More »

Avoid leaking domain logic

Many software architectures try to separate domain logic from other parts of the application. To follow this practice we always need to know what actually is domain logic and what is not. Unfortunately this is not always that easy to separate. If we get this decision wrong, domain logic can easily leak into other components and layers. We will go ...

Read More »

Logging Side Effects

One would like to assume that turning logging on would have no side effect on the running software. LOGGER.info("The current session is {}", request.getSessionId()); However, there are always ways in which logging can cause more work, or even a state change. In the above, let’s say the getSessionId needed to pull the session id down through the request from some ...

Read More »

Execute mTLS calls using Java

Previously we secured an Nginx instance using SSL and mTLS. If you are using Java interacting with a service secured with mTLS requires some changes on your code base. On this tutorial we shall enable our Java application to use mTLS using different clients. To get started fast, we shall spin up a server exactly the same way we did ...

Read More »

Overhead added by collecting thread dumps

A thread dump is a snapshot of all the threads running in a java process. It’s a vital artifact to troubleshoot various production problems such as CPU spikes, unresponsiveness in the application, poor response time, hung threads, high memory consumption. Thus to facilitate troubleshooting, we have seen enterprises capture thread dumps on a periodic basis (every 5 minute or 2 ...

Read More »

Performance impact of java.lang.System.getProperty()

‘java.lang.System.getProperty()’ is a common API used by Java developers to read the System properties that are configured during application startup time. i.e. when you pass “-DappName=buggyApp” as your application’s startup JVM argument, the value of the ‘appName’ system property can be read by invoking the ‘java.lang.System.getProperty()’. Example: public static String getAppName() { String app = System.getProperty("appName"); return app; } When ...

Read More »

Chasing Java’s release train: JDK-17, the next big thing

Here we go, JDK-17, the next LTS release, just became generally available. It is an important milestone for the OpenJDK for years to come but sadly, Project Loom, the most anticipated improvement of the JVM platform, was not able to make it, despite the extraordinary progress being made. Well, if you are still on JDK-8, like the majority of us, ...

Read More »