The Auction That Closed Instantly — Java Bug Hunt

Inspired by the unit-mismatch outages that hit marketplaces: one side of a comparison speaks seconds, the other milliseconds, and suddenly every auction on…

  • Language: Java
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Time, Units
  • Modelled on: eBay-class markets
  • Visible tests: an auction with time left is open; the closing instant closes it
  • Reward: 50 XP for a complete fix

Briefing

Inspired by the unit-mismatch outages that hit marketplaces: one side of a comparison speaks seconds, the other milliseconds, and suddenly every auction on the site is "already ended".

AuctionClock.java mixes the two.

Bug report

BUG-SNIPE · Priority: Critical · Reported by: marketplace

isClosed(closeAtSeconds, nowMillis) — auctions close AT the closing instant:

  • 1 second before -> open
  • exactly at close -> closed
  • 1 second after -> closed

Observed: every auction reports closed the moment it is listed, because epoch milliseconds are ~1000x larger than epoch seconds.

Logs

[auction] listed at 1700000000s, closeAt=1700086400s, now=1700000000123ms -> CLOSED

The code as shipped

AuctionClock.java (editable)

class AuctionClock {
    static boolean isClosed(long closeAtSeconds, long nowMillis) {
        return nowMillis >= closeAtSeconds;
    }
}

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Java bug hunts.