Implement Java version of COBOL merge_sort_test.cbl#1
Implement Java version of COBOL merge_sort_test.cbl#1devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
Co-Authored-By: Shawn Azman <shawn.d.azman@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| String line = String.format("%-5s%-50s%-50s%-5s%-25s", | ||
| record.getCustomerID(), | ||
| record.getLastName(), | ||
| record.getFirstName(), | ||
| record.getContractID(), | ||
| record.getComment()); |
There was a problem hiding this comment.
🔴 String.format does not enforce maximum field width, breaking round-trip with FileReader
In FileWriter.java:17, the format string "%-5s%-50s%-50s%-5s%-25s" uses minimum-width specifiers but does not enforce maximum widths. In Java, %-5s means "left-justify with minimum width 5" — if a string is longer than 5 characters, it will NOT be truncated. This means if any field value exceeds its designated column width (e.g., a customerID longer than 5 chars), the total line length will exceed 135 characters, and FileReader.java:20-24 will parse the fields at wrong positions, silently producing corrupt CustomerRecord objects. The fix is to use precision in the format specifiers: "%-5.5s%-50.50s%-50.50s%-5.5s%-25.25s".
| String line = String.format("%-5s%-50s%-50s%-5s%-25s", | |
| record.getCustomerID(), | |
| record.getLastName(), | |
| record.getFirstName(), | |
| record.getContractID(), | |
| record.getComment()); | |
| String line = String.format("%-5.5s%-50.50s%-50.50s%-5.5s%-25.25s", | |
| record.getCustomerID(), | |
| record.getLastName(), | |
| record.getFirstName(), | |
| record.getContractID(), | |
| record.getComment()); |
Was this helpful? React with 👍 or 👎 to provide feedback.
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
PR Description
This pull request implements the Java version of the COBOL program
merge_sort_test.cbl. The implementation includes the following classes:CustomerRecord: Represents the customer data structure with exact field sizes.FileReaderandFileWriter: Handle fixed-width record I/O matching COBOL's behavior.MergeSortProcessor: Implements the merge and sort operations.The program workflow includes:
test-file-1.txtandtest-file-2.txt).customerIDintomerge-output.txt.contractIDintosorted-contract-id.txt.Ticket ID: MBA-18
Link to Devin run: https://app.devin.ai/sessions/c7c6f573566a4418bc9b3ec459ee7d26
Requested by: Shawn Azman (shawn@cognition.ai)