Bug: Booking ID is null when creating bookings in MovieTicketBookingSystem

Author: ankit-git00Created Sep 12, 2026Updated Sep 12, 2026

Problem

When creating a booking in the MovieBookingService, the booking ID is never set, resulting in a null ID value. This is visible when trying to print the booking ID in the demo.

Root Cause

In BookingManager.createBooking(), the BookingBuilder is instantiated without calling .setId():

java
Booking booking = new Booking.BookingBuilder()
        .setUser(user)
        .setShow(show)
        .setSeats(seats)
        .setTotalAmount(totalAmount)
        .setPayment(payment)
        .build();  // ID is never set!

Since setId() is never called, the id field in the builder remains null, and the Booking object is created with a null ID.

Impact

  • booking.getId() returns null
  • Demo output shows: Booking ID: null
  • This makes it impossible to track or retrieve bookings by ID

Expected Behavior

Each booking should have a unique ID automatically generated upon creation.

Solution

Generate a unique booking ID using UUID.randomUUID().toString() before building the Booking object.

Files Affected

  • solutions/java/src/movieticketbookingsystem/BookingManager.java

Source: ashishps1/awesome-low-level-design