tiltwind commented on PR #401: URL: https://github.com/apache/dubbo-go-hessian2/pull/401#issuecomment-6766163711
The two new cases are the right regression for #351: on master they fail with `the type ref index 0 is out of range` and `the type ref index 1 is out of range`, and with this change they decode to the expected struct. Both fixtures have a single map field, and that field's type is a fresh class name. The integer refs sit on the nested maps, which already go through `decMap`. `decMapByValue` now calls `decMapType`, and two branches of that call are still untested. **1. Second map field whose type is an integer ref, then a list that uses the next index.** `decMapType` records a new type name and, for an integer ref, looks it up without recording another entry. `decString` turns a compact int into a decimal string and drops it. A fix that reads the type with `decString` and always appends it still passes both current cases, and shifts every later index once a field type is a ref. Please add one holder, field order fixed so the ref numbers stay stable: - `first`: `LinkedHashMap` (type name, index 0), scalar entries - `second`: `LinkedHashMap` (type ref 0), scalar entries - `tags`: `ArrayList` (type name, index 1) - `tagsAgain`: `ArrayList` (type ref 1) `HashMap` does not work here: `MapSerializer` writes it as an untyped `H`, so the field type never enters `_typeRefs`. Lists do: `CollectionSerializer` writes the class name, and `writeListBegin` uses the same `_typeRefs` as maps. On master the two map types are dropped, `ArrayList` is recorded as index 0, and `tagsAgain` fails with `can't find ref list type at index 1`. Appending every `decString` result fails too: the ref `0` is appended as the type name `"0"`, so index 1 is that extra map type and the list decode no longer sees `ArrayList`. `decMapType` keeps index 1 as `ArrayList`. A list nested inside the single map field is already covered by the existing ref-1 case. The missing part is the integer ref on the field header itself. **2. Out-of-range type ref on the map field.** hessian-lite will not emit this. A raw buffer is enough: `'M'`, `0x90` (int 0), `'Z'`, decoded into a map field while the type-ref list is empty. `decString` accepts that int and the value is ignored, so master decodes an empty map. `decMapType` returns `the type ref index 0 is out of range`. That is the behavior change called out in the PR, and nothing locks it. `HashMap`, deeper nesting, and a Go round-trip do not need new tests. The Go encoder writes `H`, or a full type string on every map, so those tests pass on master. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
