Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Stop NullPointerExceptions Before Production in Spring Boot 4 with Null Safety

Dan Vega via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn to eliminate NullPointerExceptions in production applications using Spring Boot 4's revolutionary null safety features with JSpecify annotations. Discover how to leverage @NullMarked, @Nullable, @NonNull, and @NullUnmarked annotations to make nullness explicit in Java code and catch potential null pointer issues at compile-time rather than runtime. Explore the implementation of package-level null safety using package-info.java files, integrate NullAway for compile-time null checking, and work with nullable elements in collections and arrays while maintaining type safety. Master real-world patterns for handling null values in Spring services and controllers through practical examples with a coffee shop application, including building user services with potential null returns, working with nullable fields in Coffee classes and records, handling nullable elements in collections through Review Service examples, and implementing arrays with nullable elements in Menu Service scenarios. Understand why Spring Framework 7 and Spring Boot 4's null safety features represent a fundamental shift in Java development, providing the same confidence boost as comprehensive testing while preventing the billion-dollar mistake of implicit null references from reaching production environments.

Syllabus

00:00 - The billion-dollar mistake and why nullness being implicit is problematic
02:17 - Setting up Spring Boot 4.0 RC1 project with dependencies
04:35 - Building the User service with potential null returns
07:42 - Demonstrating the classic NullPointerException scenario
09:06 - Introduction to JSpecify's 4 annotations @NullMarked, @Nullable, @NonNull, @NullUnmarked
10:15 - Implementing package-level null safety with package-info.java
13:28 - Adding NullAway for compile-time null checking
16:42 - Working with nullable fields in Coffee class and records
18:35 - Handling nullable elements in collections Review Service example
20:47 - Arrays with nullable elements Menu Service implementation
22:15 - Why this matters: Building confidence like you do with tests

Taught by

Dan Vega

Reviews

Start your review of Stop NullPointerExceptions Before Production in Spring Boot 4 with Null Safety

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.