TypeScript’s Great Divide: Understanding undefined vs. null

In the world of JavaScript and TypeScript, few concepts create as much quiet confusion as undefined and null. Both seem to represent “nothing,” yet they are not the same. Misunderstanding the distinction can lead to subtle bugs and unexpected behavior. Let’s clear the air once and for all.

Think of them as two different kinds of “emptiness.” One is accidental, the other is intentional. Mastering this difference is a key step toward writing cleaner, more predictable code.

Meet undefined: The Sound of Silence

undefined is a primitive value that TypeScript (and JavaScript) uses to signify that a variable has been declared but has not been assigned a value. It’s the default state of “not yet initialized.” It’s the system telling you, “I have a space for this, but nothing’s in it yet.”

Continue reading TypeScript’s Great Divide: Understanding undefined vs. null

Securing Spring MVC with SiteMinder Pre‑Authentication – A Step‑by‑Step Guide

Enterprise Java applications frequently live behind a corporate Single Sign-On (SSO) gateway such as Broadcom (formerly CA) SiteMinder. SiteMinder authenticates users at the reverse-proxy layer — before any request ever reaches your application server — and then injects the verified identity into a well-known HTTP request header (typically SM_USER). Your Spring Boot application simply trusts that header and builds a security context from it, with no login form and no password handling of its own.

This pattern is called pre-authentication: the heavy lifting of credential verification is delegated to an external system, and your app only needs to map the already-authenticated identity to application-level roles. Spring Security has first-class support for this via RequestHeaderAuthenticationFilter and PreAuthenticatedAuthenticationProvider.

This tutorial walks through a complete Spring Boot 3.x / Spring Security 6.x configuration, covering Maven dependencies, the security filter chain using the modern lambda DSL, a UserDetailsService implementation, and tips for testing locally without a real SiteMinder agent.

Continue reading Securing Spring MVC with SiteMinder Pre‑Authentication – A Step‑by‑Step Guide

Leveraging Virtual Threads in Spring Boot 3.4+: Building High-Throughput Services

I’ve been shipping Java services for over a decade. I’ve tuned Tomcat thread pools, profiled connection leaks, and once reluctantly rewrote a critical service in WebFlux because blocking threads were killing us at scale. So when Java 21 landed with virtual threads baked in, I didn’t just read the JEP — I immediately threw it at a production-like load test.

The results were not subtle. This post is what I wish existed back then: an honest, methodical walkthrough of enabling virtual threads in Spring Boot 3.4, with real benchmark methodology, the gotchas that will actually bite you in production, and a clear-eyed take on when virtual threads won’t help at all.

Continue reading Leveraging Virtual Threads in Spring Boot 3.4+: Building High-Throughput Services

Spring Boot RestTemplate with Basic Auth: A Modern Guide

Communicating between microservices is a fundamental aspect of modern application development. Often, these services need to be secured. One of the simplest and most widely supported methods for securing REST APIs is Basic Authentication. In this guide, we’ll walk through how to configure and use Spring Boot’s RestTemplate to consume a REST API protected with Basic Auth.

We’ll cover the modern, recommended approach using Spring Security’s component-based configuration, updating older patterns you might find in other tutorials.

Project Setup

First, ensure your Spring Boot project includes the spring-boot-starter-web dependency. This starter conveniently bundles everything we need, including Spring MVC for creating the REST service, Tomcat as the embedded server, and RestTemplate support.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

You’ll also need the spring-boot-starter-security dependency to enable security features.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
Continue reading Spring Boot RestTemplate with Basic Auth: A Modern Guide

8086 Assembly Program for Bitwise Operations: AND, OR, XOR, and NOT

This blog post will walk you through a simple 8086 assembly program designed to perform bitwise operations: AND, OR, XOR and NOT on 8-bit numbers. While these operations have a straightforward purpose, they are foundational when working at low level, manipulating bits, flags and registers. Let’s get started!

data segment
    a      db  0Ah        ; first 8-bit operand (10 decimal)
    b      db  05h        ; second 8-bit operand (5 decimal)
    res_and  db  ?        ; result of a AND b
    res_or   db  ?        ; result of a OR b
    res_xor  db  ?        ; result of a XOR b
    res_not  db  ?        ; result of NOT a
data ends

code segment
    assume cs:code, ds:data

start:
    mov ax, data
    mov ds, ax

    ; load operands into registers
    mov al, a
    mov bl, b

    ; AND operation: AL = AL AND BL
    and al, bl
    mov res_and, al

    ; reload operands for next operation
    mov al, a
    mov bl, b

    ; OR operation: AL = AL OR BL
    or al, bl
    mov res_or, al

    ; reload operands for next operation
    mov al, a
    mov bl, b

    ; XOR operation: AL = AL XOR BL
    xor al, bl
    mov res_xor, al

    ; NOT operation on first operand: AL = NOT AL
    mov al, a
    not al
    mov res_not, al

    int 3                ; breakpoint / stop for debug

code ends
end start
Continue reading 8086 Assembly Program for Bitwise Operations: AND, OR, XOR, and NOT

Solved: Bean property ‘configurationClass’ is not writable or has an invalid setter method

Every developer has those moments where a seemingly simple task turns into a head-scratching puzzle. This error, encountered while trying to configure a custom LocalSessionFactoryBean in Spring Boot, is a perfect example of a subtle type mismatch causing a cryptic failure.


The Scenario and the Error

The goal was to set up a custom SessionFactory bean using Spring’s LocalSessionFactoryBean. The initial, problematic configuration was:

@Configuration
public class HibernateConfig {
    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        // … set data source, hibernate properties …
        
        // This line caused the error!
        sessionFactory.setConfigurationClass(org.hibernate.cfg.Configuration.class); 
        
        return sessionFactory;
    }
}

This configuration resulted in the following exception upon application startup:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': 
Bean property 'configurationClass' is not writable or has an invalid setter method. 
Does the parameter type of the setter match the return type of the getter?
Continue reading Solved: Bean property ‘configurationClass’ is not writable or has an invalid setter method

Mastering the Core of TypeScript: A Practical Guide to Types

If you’ve spent any time with JavaScript, you’ve likely encountered the infamous undefined is not a function error. It’s a rite of passage. These runtime errors happen because JavaScript is dynamically typed, meaning it only figures out the “type” of a variable (like a string, number, or object) when the code is actually running.

TypeScript changes the game by adding a layer of static types on top of JavaScript. Think of it as a super-smart linter that understands the shape of your data. By defining types *before* you run your code, you can catch a huge class of bugs right in your editor. This is the core promise of TypeScript, and it all starts with understanding its type system.

Let’s dive into the essential TypeScript types you’ll use every day, moving from the simple to the more complex.


The Basics: Type Annotation Syntax

First, how do you even tell TypeScript about a type? You use a colon : after a variable or function parameter name, followed by the type.

let framework: string = "React";
let version: number = 18;
let isAwesome: boolean = true;

// This will now cause an error in your editor!
// version = "eighteen"; // Error: Type 'string' is not assignable to type 'number'.
Continue reading Mastering the Core of TypeScript: A Practical Guide to Types