Demo · Apache DayTrader

A 2010 Java trading application, rewritten and proven against itself.

DayTrader is an online stock-brokerage application that IBM built for WebSphere and gave to the Apache Geronimo project. We ran the official 2.1.7 release on its original application server, recorded what it does, and rewrote it as plain Java 21 on PostgreSQL, one slice at a time, until the new code gave the same results: to the cent, to the second and to the row.

recorded cases
43
web requests compared
130
table rows compared
124,733
rows migrated and proven
2,899
approved changes
10

Status, October 2026: slices 1 to 3 (orders, accounts, pages) and the data migration proven against the original; asynchronous orders documented, not rewritten. Every recorded case can be replayed on AWS in the Parity Lab.

1 · The system

Java EE 5, two copies of the business logic, and a random number generator

DayTrader 2.1.7 is about 20,000 lines of Java and 4,100 lines of JSP: EJB 3 session beans, JPA entities, servlets and JSP pages, JMS queues and a SOAP service, on Apache Geronimo 2.1.7 and Java 5. Users register, sign in, look up quotes, buy and sell shares, and look at their portfolio and account. It is Apache 2.0 licensed, and an old Java EE application of a kind many companies still run.

  • The business logic exists twice. One implementation uses JPA, the other plain JDBC, and a runtime switch picks one. They already disagree on a rule: the JDBC version halves any stock price above $400, the JPA version never does.
  • Prices move at random. Every trade multiplies the price by a random factor between 0.8 and 1.2, from a generator seeded with the clock, and order and login times come from the clock too.
  • Share quantities are floating-point numbers, turned into exact decimals only for money.

2 · Recording the original

The 2010 server, run once and recorded

The original needs Java 6 and its 2010 application server, so it ran in a container on our machine, with PostgreSQL in place of its embedded database.

  1. Make it repeatable

    A small test switch, 72 changed lines published with the recordings, reseeds the random generator and fixes the clock for each case. Nothing else in the release is changed.

  2. Record every case

    Each case is a short sequence of web requests: buys, sells, logins, registrations, profile changes and page views, including the awkward ones (selling twice, 0.1 shares, someone else's holding, HTML in a name). For every request the recorder keeps the page the server sent, and after each case all six tables.

  3. Replay on the new code

    The new code starts from the same tables, with the same random numbers and the same clock, and answers the same requests. A comparator reads each recorded page into the values it shows and compares them with the new code's, then compares every table row.

3 · The slices

What moved, and what was proven

SliceWhat movesCasesResult
1Pricing and orders: buys, sells, fees, holdings, balances, price moves, the market index14 cases, 39 requests14 of 14 identical, 3 with an approved change; 40,630 rows compared
2Accounts and login: register, sign in and out, profile changes, passwords17 cases, 39 requests17 of 17 identical, with approved changes; 49,293 rows compared
3The trading pages: home, portfolio, quotes, order confirmation, account12 cases, 52 requests12 of 12 identical apart from approved changes; 34,810 rows compared
4Asynchronous orders over JMS-Documented, not rewritten: the owner chose synchronous orders only
5Data migration and cutover2,899 rowsIdentical: six tables copied, 200 passwords converted and verified

The new code is plain Java 21 with no framework: the business rules as small services, the original SQL on PostgreSQL, and a web front end on the JDK's own HTTP server with every value escaped. On AWS it runs against Amazon Aurora Serverless, a fresh schema for every Parity Lab run.

4 · Slices 1 and 2

The money, then the accounts

  1. Slice 1: to the cent

    Fees, balances, holdings, the random price moves, the stock split rule and the market index match on every case, including the index average to all 16 decimal places PostgreSQL prints. The first run matched 13 of 14 cases. The one difference was a crash: selling a holding a second time throws a NullPointerException in the original. The new code returns a cancelled order instead, as the JPA version does, as approved change #1. The tables are identical either way.

  2. Slice 2: passwords become hashes

    Passwords are stored as PBKDF2 hashes (600,000 iterations, a random salt per user) instead of plain text, approved change #2; the comparison checks that each hash verifies the original's password. A failed sign-in no longer prints the typed password back (#3), the closed-order alert runs only after a successful sign-in (#4), and the account data never carries the password or the full card number (#5). Two more were approved later: an opening balance that is not a number crashes the original, while the new code refuses it (#10); and HTML in a profile, stored the same way on both, is escaped in the new pages (#7).

5 · Slice 3

The pages, value by value

The new pages have a new layout, so the layout is not compared. What each page says is: every balance, holding, gain, quote, order and message, read from the recorded page and compared with the new page's data.

  • Approved changes. The original home page crashes ("Rounding necessary") once anyone holds a fractional share; the new one rounds the total to the cent (#6). Every value is escaped, so HTML in a name no longer runs in the browser (#7). Selling someone else's holding is refused and nothing is written (#8). A buy of an unknown stock, or of a quantity that is not a number, gets a message instead of an HTTP 500 (#9).
  • What the comparison caught in the port. A quote request for a symbol longer than ten characters, or for no symbols at all, shows an all-zero "Invalid symbol" row in the original. The port missed that rule until the recording showed it; it is in now.
  • Where the original is not deterministic. The account page's "last five orders" come from a query with no sort order, so the database decides which five, and in what order. The comparison treats the same orders in another order as the same page, and the finding goes on the list.

6 · Slices 4 and 5

Asynchronous orders, and moving the data

  1. Asynchronous orders: documented

    In its asynchronous mode the original sends each order to a JMS queue and completes it later in a message-driven bean, and publishes price changes on a topic. The owner chose synchronous orders only. If a client needed the asynchronous mode, the equivalent would be an Amazon SQS queue with a worker completing each order once, and Amazon SNS for prices; the check would compare end states, since timing differs by design.

  2. The data migration: copied and proven

    The new code keeps the original's six tables, so the migration is a copy with one change: plain-text passwords become hashes. The tool copies every table, converts every password, then proves the copy: each row compared, each hash verified against the original password, and each id counter checked to be above every id already in use. On the sample data: 2,899 rows identical, 200 passwords converted and verified.

7 · Findings

What the tests found in the original

  • Any signed-in user can sell anyone's holdings: the original checks the holding number, not its owner. Recorded: one user sold another's 86 shares and was credited $13,369.55.
  • A failed sign-in shows the typed password on the page and writes it to the log, and passwords are stored in plain text.
  • Anyone can mark another user's orders as completed by trying to sign in as them with any password: the order alert runs before the password check.
  • The account page sends the stored password back to the browser, twice, and shows the full card number; names and addresses are written into the pages unescaped.
  • A buy can overdraw the account, registration accepts a negative opening balance, and every registration error ends in the same vague message.
  • The home page crashes once a user holds a fractional share.
  • The two data-access modes disagree on stock splits, and a stock's daily low and high never change.
  • The quote page drops unknown symbols without a word, and gain percentages are rounded to whole percent.

Each one is either kept for parity and reported, or fixed as a numbered change; ten changes are approved, each with the recorded cases that show it.

8 · Limits

What this does not prove yet

  • The recordings cover the cases we wrote, 43 of them. A production project would add recordings of real traffic.
  • The original ran on PostgreSQL, not its embedded database, so behavior that depends on the database is PostgreSQL's in both runs.
  • The SOAP service, the Dojo front end and the desktop clients are out of scope, as is the asynchronous order mode.
  • Not yet a production setup. The new code runs on AWS in the Parity Lab, on AWS Lambda and Amazon Aurora Serverless, for tests. A production setup would add the web front end behind a load balancer, monitoring and the cutover rehearsals the migration tool is built for.

Replay the recorded cases in the Parity Lab · Back to all demos

Want this for your system?

A two-to-three-week assessment maps your system, finds the risks and gives you a fixed price for the first slice.

Book an assessment call