Repository navigation
#3945 / #3946 / #3949 / #3950: generated Java reads KSDS files in key order, rejects bad timestamps and packed data, and keeps decimal scale - #3951
Merged
Conversation
… order, rejects bad timestamps and packed data, and keeps decimal scale - #3945: a batch sequential READ orders by the file's order (KSDS: the code-page sort column or the key; RRDS: RRN id; ESDS: generated id / entry order) instead of a bare findAll(). - #3946: Db2Dates.parseTimestamp takes ASCII digits only; invalid -> DateTimeParseException like parseDate. - #3949: EbcdicDecoderUtil.unpackComp3 and CobolRecords.packed throw on invalid nibbles (S0C7) instead of 0. - #3950: VSAM entity / key-class BigDecimal columns carry @column(precision, scale) from the PICTURE. - Cultural Gauntlet: the executed read-all runs the generated readAll's ORDER BY; baseline now empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5
Contributor
…smoke-test ruff) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3945
Fixes #3946
Fixes #3949
Fixes #3950
The last four open items on "GitGalaxy Tours the Globe". All four are generator changes to the generated Java record layer. The engine is untouched, and the golden masters did not move.
#3945: a sequential READ of a KSDS comes back in key order
Why: the batch branch of
RepositoryForge._service_methodsgeneratedreadAll{name}()as a barefindAll(). That sends noORDER BY, so records came back in the database's order: heap order on PostgreSQL, code-point PK order on H2. The mainframe returns them in key order. This silently changed control breaks and merge/match logic.What: the new
RepositoryForge._file_order(st)picks the order. The method is nowreturn repo.findAll(org.springframework.data.domain.Sort.by(...));. The FQN matches the existingPageRequest.ofusage and avoids a clash with a generated class namedSort. A comment above the method says which order it uses and why.culture.key_collation: ebcdic(default)Sort.by("<key>Sort"), the #3822 code-page sort column the CICS browse finders already usebinary/databasecollationSort.by("<key>")@EmbeddedId)Sort.by("id.<part1>", "id.<part2>", ...). Under ebcdic with a text part, a TODO says the text parts follow the DB collation, not code-page bytes (no sort column exists for a composite key)NUMBERED)Sort.by("id"), the relative record numberNONINDEXED)Sort.by("id"). Entry (RBA) order, which the@GeneratedValueid follows as rows are addedvsamKey)Sort.by("vsamKey"), with a TODO under ebcdic (no sort column)Other generated multi-record reads I checked:
findById. No multi-record read.ACCESS DYNAMICREAD NEXT has never been generated (only the keyed read), so nothing changes there.DatasetResolver(Java conversion: JCL job flow -> Spring Batch jobs #3622), so they keep their natural byte order. Unchanged.The new TODO wording is filed under the worklist's
vsam-keycategory.#3946:
Db2Dates.parseTimestamptakes ASCII digits onlyBefore
Integer.parseIntruns, the time part must be hour 1–2 digits, minutes and seconds exactly 2, and fraction 0–12 digits, all ASCII0-9(new privatedigits()check). This rejects Arabic-Indic and full-width digits and signs like+1.Invalid input throws
DateTimeParseException("not a DB2 timestamp: ..."). That is the exceptionparseDate/parseTimealready throw for DB2's -180 / -181. An out-of-range time is wrapped in the same exception, and so is a string too short to hold a time (it used to throwStringIndexOutOfBoundsException). The date part still goes throughparseDate.#3949: invalid packed decimal is a data exception, not ZERO
EbcdicDecoderUtil.unpackComp3(decoder forge) now throws the new nestedEbcdicDecoderUtil.PackedDecimalDataExceptionwhen it finds:NumberFormatException, so existing catches still work.invalid packed decimal (S0C7 data exception) in WS-AMT: digit nibble A at byte 1 of 3.unpackComp3(bytes, scale, field)names the field; the 2-arg form passes null.catch (Exception) -> ZEROand the "Defaulting to ZERO" warnings are gone.CobolRecords.packed(repository forge; the entities'fromRecordreads COMP-3 through it) had the same flaw. A 0-9 sign nibble decoded as positive, and it never checked digit nibbles. It now throwsNumberFormatException("invalid packed decimal (S0C7): byte X'..' at offset N, a digit nibble above 9 | a sign nibble below A"), matching howzonedalready rejects bad data (Java runtime accepts non-ASCII digits as numbers (Arabic-Indic, Devanagari, full-width) where COBOL NUMERIC/NUMVAL would not #3831).fromRecorddecodes eagerly. A record whose packed field holds LOW-VALUES now throws on load. On z/OS only arithmetic on that field would S0C7, but this is the same eager choicezonedalready makes for spaces.#3950: VSAM BigDecimal columns keep their precision and scale
The new
_decimal_attrs(f)addsprecision = <digits>, scale = <decimals>to every BigDecimal@Columnof a VSAM entity and of its@EmbeddedIdkey class. Existing attributes (name,length,columnDefinition,@Id) stay as they were.S9(5)V9(4)givesprecision = 9, scale = 4.S9(7)V99 COMP-3gives9, 2.S9(20)gives20, 0.parse_pic_precision, the function the schema forge uses.9/S/V/Ppictures become BigDecimal (java_type). An edited or currency-edited picture is its display text, aStringcolumn of its byte width. So no currency symbol (PICTURE SYMBOL 'U' currency mis-sizes the schema: UUU,UU9.99 -> DECIMAL(3, 2) #3910) or DECIMAL-POINT IS COMMA can move a digit of a BigDecimal field here, and no currency symbols are passed. The Spring clean-room entity already applies PICTURE SYMBOL 'U' currency mis-sizes the schema: UUU,UU9.99 -> DECIMAL(3, 2) #3910's currency-aware precision; a test pins that as well.Pscaling:Ppositions widen the precision:SVPP9(3)gives5, 5.FIXED DEC(p,q)getsp,q.FIXED BINand negative scales get none.AnnotatedColumn). Whenprecision > 0it applies the annotation's precision and scale, soscale = 0is honoured.Cultural Gauntlet
collation-dblayer'sread-allprobe used to hard-codeSELECT key FROM table(no ORDER BY), the SQL a barefindAll()sends. It now runs the SQL the generatedreadAllsends. The newread_all_sql()mapsSort.byproperties to the entity's@Columnnames; a barefindAll()still yields no ORDER BY._COLLATION_WHAT["read-all"]text was updated. Three gauntlet unit tests that asserted the ledgered Generated batch sequential READ of a KSDS is findAll(): records come back in database order, not key order #3945 / Generated Db2Dates.parseTimestamp accepts Arabic-Indic / full-width digits in the time (Integer.parseInt) #3946 failures now assert that those cells pass.--full --run --dbcollation-static, 24collation-db, 24 `input_*tests/cultural_gauntlet/baseline.txt--ci/--full --ci/--full --run --db --ciSnapshot changes (re-blessed deliberately)
tests/cobol_mainframe/refraction_snapshot/{excerpts,full}/<6 corpora>/, 36 files:java/src/main/java/.../util/EbcdicDecoderUtil.java.snap: the Generated EbcdicDecoderUtil.unpackComp3 turns corrupt packed data into ZERO instead of failing #3949 decoder.java/guardrail_baseline.json.snap: the decoder file's sha256 changed, and the guardrail now lists the nested classPackedDecimalDataExceptionand the private helperinvalid.java/java_migration_audit.txt.snap: the guardrail class count is +1 (the nested exception class).The snapshot corpora generate no VSAM repositories or Db2Dates, so #3945 / #3946 / #3950 move no snapshot.
tests/tools_recorders/test_decoder_forge.py's golden image was updated for the same reason. Golden masters (engine) did not move.Tests
New file
tests/cobol_mainframe/test_generated_record_layer.py(15 tests; 14 fail on main). Where behaviour matters, it compiles and runs with the JDK, using the gauntlet'sjdk():binary/databaseString key, a numeric key, a group key, RRDS and ESDS; no generated sequential read is a barefindAll(). The executed proof in H2 and PostgreSQL is the gauntlet'scollation-db.parseTimestampover 13 inputs: valid (1-digit hour, 12 fraction digits) and invalid (Arabic-Indic, full-width, sign, out of range, 13 fraction digits, no time, Arabic date). Every invalid one givesDateTimeParseException.unpackComp3andCobolRecords.packeddecode valid C/D/B/F/A-signed data and throw on each bad nibble kind (bad low digit, bad high digit, digit in the sign, LOW-VALUES sign, shifted field);PackedDecimalDataExceptionis aNumberFormatException.S9(5)V9(4), a COMP-3 field,S9(20),SVPP9(3), a currency-edited field (String, width only), an Integer (none), and a group-key class column; the Spring entity's PICTURE SYMBOL 'U' currency mis-sizes the schema: UUU,UU9.99 -> DECIMAL(3, 2) #3910 currency precision (UUU,UU9.99gives7, 2); and a round trip through H2 that keeps12345.6789.Gates
tests/tools/pr_gates.py(full): lint, audits, secrets, xray, gauntlet, golden, suite. 7/7 pass.EQUIVALENCE_E2E=1, Docker GnuCOBOL, JDK 17): test_equivalence, test_equivalence_inputs, test_equivalence_cics, test_equivalence_environments, test_rounding, test_regional_options. 93 passed.git merge origin/main: already up to date when pushed, so the gate results above are for this exact tree.🤖 Generated with Claude Code
https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5