Commit 3580f6e
Fix type compatibility issues in DefaultRailWayNetGrid
Changes:
- Fix putMap signature to accept java.util.Map directly
- Fix PointIterator.remove() to save cell value before delegate removal
- Add removeAll() override in KeySet to avoid ConcurrentModificationException
- Update test code to use java.util.HashMap with explicit casts
Technical details:
1. Changed putMap(Map<Point, TrackBlockPart>) to putMap(java.util.Map<Point, TrackBlockPart>)
- Kotlin's Map interface was causing type inference issues with internal cast
- Direct java.util.Map parameter eliminates the cast
2. Fixed PointIterator.remove() ordering bug:
- Entry.getValue() calls Array2DMap.get(key) which fails after delegate.remove()
- Must save cell value BEFORE removing from underlying map
- This fixes NullPointerException in iterator remove operations
3. Added KeySet.removeAll() override:
- AbstractSet.removeAll() iterates while calling remove(), causing ConcurrentModificationException
- New implementation collects cells first, then removes in batch
- Maintains reverse table consistency throughout
4. Updated tests to use java.util.HashMap with explicit casts:
- mapOf() creates immutable Kotlin Map that doesn't cast properly
- HashMap instances cast correctly to java.util.Map interface
All tests now pass: 698 unit tests (668 passed, 30 skipped) + 86 integration tests
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent ffe4048 commit 3580f6e
3 files changed
Lines changed: 57 additions & 30 deletions
File tree
- src
- main/kotlin/cz/vutbr/fit/interlockSim/context
- test/kotlin/cz/vutbr/fit/interlockSim/context
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
| 305 | + | |
305 | 306 | | |
306 | 307 | | |
307 | | - | |
| 308 | + | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| |||
Lines changed: 32 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | | - | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
64 | 93 | | |
65 | 94 | | |
66 | 95 | | |
| |||
87 | 116 | | |
88 | 117 | | |
89 | 118 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 119 | + | |
| 120 | + | |
94 | 121 | | |
95 | 122 | | |
96 | 123 | | |
| |||
Lines changed: 22 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
434 | 433 | | |
435 | 434 | | |
436 | | - | |
| 435 | + | |
437 | 436 | | |
438 | 437 | | |
439 | 438 | | |
| |||
451 | 450 | | |
452 | 451 | | |
453 | 452 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
459 | 457 | | |
460 | 458 | | |
461 | | - | |
| 459 | + | |
462 | 460 | | |
463 | 461 | | |
464 | 462 | | |
| |||
476 | 474 | | |
477 | 475 | | |
478 | 476 | | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
485 | 482 | | |
486 | 483 | | |
487 | 484 | | |
| |||
497 | 494 | | |
498 | 495 | | |
499 | 496 | | |
500 | | - | |
| 497 | + | |
501 | 498 | | |
502 | 499 | | |
503 | 500 | | |
| |||
534 | 531 | | |
535 | 532 | | |
536 | 533 | | |
537 | | - | |
538 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
539 | 537 | | |
540 | 538 | | |
541 | 539 | | |
| |||
586 | 584 | | |
587 | 585 | | |
588 | 586 | | |
589 | | - | |
590 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
591 | 590 | | |
592 | 591 | | |
593 | 592 | | |
| |||
0 commit comments