Commit 6a29484
Harden serialization: fail on unknown tags, fix char encoding (#284)
* Harden serialization: fail on unknown tags, fix char encoding
Three scoped fixes to the serialization layer. No change to the on-disk
format, so no VERSION bump.
- deserialize() silently returned null for an unrecognized type tag,
surfacing later as a confusing ClassCastException or silent data loss.
It now throws IOException naming the tag. The preceding `case -1` was
unreachable (readUnsignedByte never returns -1) and is removed.
- CHAR and CHAR_ARRAY relied on DataOutput.writeChar/readChar, but
DataInputOutput implements those with 4 bytes instead of the 2 the
interface specifies. Production writes via DataOutputStream, so no
stored data is affected, but graphstore's own tests were round-tripping
an encoding that never reaches disk. Both sides now use
writeShort/readUnsignedShort, which is byte-identical to
DataOutputStream.writeChar, and DataInputOutput.writeChar/readChar are
fixed to honour the contract.
- Dropped Locale support. Locale is not an AttributeUtils supported type,
so it cannot enter a graph through the public API. Tag 124 is kept
reserved so it is never reused.
Adds a test asserting all serialization tag constants are distinct.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Cover non-ASCII chars in serialization tests
The char tests only used ASCII values, so they could not detect a
narrowing of the 2-byte encoding. Extend them across the boundaries of
the 16-bit range: above 0x7F, above 0x7FF, either side of the
signed-short flip, the 16-bit maximum, and an unpaired surrogate.
Verified by temporarily narrowing CHAR to a symmetric 1-byte encoding,
which the previous values did not catch.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent f46c641 commit 6a29484
3 files changed
Lines changed: 40 additions & 30 deletions
File tree
- src
- main/java/org/gephi/graph/impl
- utils
- test/java/org/gephi/graph/impl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
| |||
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
| 180 | + | |
| 181 | + | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
1470 | 1471 | | |
1471 | 1472 | | |
1472 | 1473 | | |
1473 | | - | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
1474 | 1477 | | |
1475 | 1478 | | |
1476 | 1479 | | |
| |||
1520 | 1523 | | |
1521 | 1524 | | |
1522 | 1525 | | |
1523 | | - | |
| 1526 | + | |
| 1527 | + | |
1524 | 1528 | | |
1525 | 1529 | | |
1526 | 1530 | | |
| |||
1531 | 1535 | | |
1532 | 1536 | | |
1533 | 1537 | | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | 1538 | | |
1541 | 1539 | | |
1542 | 1540 | | |
| |||
2023 | 2021 | | |
2024 | 2022 | | |
2025 | 2023 | | |
2026 | | - | |
| 2024 | + | |
2027 | 2025 | | |
2028 | 2026 | | |
2029 | 2027 | | |
2030 | | - | |
| 2028 | + | |
2031 | 2029 | | |
2032 | 2030 | | |
2033 | 2031 | | |
| |||
2116 | 2114 | | |
2117 | 2115 | | |
2118 | 2116 | | |
2119 | | - | |
2120 | | - | |
2121 | | - | |
2122 | 2117 | | |
2123 | 2118 | | |
2124 | 2119 | | |
| |||
2224 | 2219 | | |
2225 | 2220 | | |
2226 | 2221 | | |
2227 | | - | |
2228 | | - | |
2229 | | - | |
| 2222 | + | |
| 2223 | + | |
2230 | 2224 | | |
2231 | 2225 | | |
2232 | 2226 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
Lines changed: 27 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | | - | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
999 | 1000 | | |
1000 | 1001 | | |
1001 | 1002 | | |
1002 | | - | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1003 | 1007 | | |
1004 | 1008 | | |
1005 | 1009 | | |
| |||
1144 | 1148 | | |
1145 | 1149 | | |
1146 | 1150 | | |
1147 | | - | |
| 1151 | + | |
1148 | 1152 | | |
1149 | 1153 | | |
1150 | 1154 | | |
| |||
1184 | 1188 | | |
1185 | 1189 | | |
1186 | 1190 | | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | 1191 | | |
1196 | 1192 | | |
1197 | 1193 | | |
| |||
1314 | 1310 | | |
1315 | 1311 | | |
1316 | 1312 | | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1317 | 1333 | | |
0 commit comments