arne-bdt opened a new pull request, #3942:
URL: https://github.com/apache/jena/pull/3942

   The spliterators claim not NULL, which was not explicitly documented and 
checked in the set and map implementations for keys and values.
   
   Now non-null key and value are ensured by assertions and documented in the 
interfaces.
   
   Also: The Spliterator claimed IMMUTABLE, which is not correct since the 
spliterators may throw ConcurrentModificationException.
   
   GitHub issue resolved #3941 
   
   Pull request Description:
   
   Two related corrections to the `jena-core` in-memory collection
   spliterators and their backing maps/sets:
   
   1. **Remove `IMMUTABLE` from spliterator characteristics.**
      `ArraySpliterator`, `ArraySubSpliterator`, `SparseArraySpliterator`,
      and `SparseArraySubSpliterator` detect concurrent modification
      (they snapshot `set.size()` and throw `ConcurrentModificationException`
      from `tryAdvance` / `forEachRemaining`). That is incompatible with
      `Spliterator.IMMUTABLE`, which requires that the element source
      cannot be structurally modified. The flag is dropped; tests that
      asserted on the characteristic value are updated.
   
   2. **Document and assert non-null keys/values.**
      The spliterators report `NONNULL`, but the map and set
      implementations never documented or enforced that constraint. The
      `JenaMap`, `JenaMapIndexed`, `JenaSet`, `JenaSetHashOptimized`, and
      `JenaSetIndexed` interfaces now state that `null` keys (and, for
      maps, `null` values) are not allowed. `assert` checks were added
      to the write paths in `FastHashMap`, `FastHashSet`, `HashCommonMap`,
      and `HashCommonSet` so violations are caught during testing.
   
   Tests in `AbstractJenaMapNodeTest` and `FastHashMapTest2` that were
   passing `null` values are updated to use real values.
   
   ## Notes
   
   - Enforcement is via `assert`, so production behavior is unchanged
     for callers running without `-ea`. No internal caller currently
     passes `null`, so no functional regression is expected.
   - Cosmetic: `FastHashSet.addUnchecked` first parameter renamed
     `value` → `key` to match the interface and the new assertion.
   
   ----
   
    - [x] Tests are included.
    - [x] Commits have been squashed to remove intermediate development commit 
messages.
    - [x] Key commit messages start with the issue number (GH-xxxx)
   
   By submitting this pull request, I acknowledge that I am making a 
contribution to the Apache Software Foundation under the terms and conditions 
of the [Contributor's 
Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   
   ----
   
   See the [Apache Jena "Contributing" 
guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
   


-- 
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]

Reply via email to