arne-bdt opened a new issue, #3941:
URL: https://github.com/apache/jena/issues/3941

   ### Version
   
   6.2.0-SNAPSHOT
   
   ### What happened?
   
   ### Description
   
   The spliterators in `org.apache.jena.mem.spliterator` —
   `ArraySpliterator`, `ArraySubSpliterator`, `SparseArraySpliterator`,
   and `SparseArraySubSpliterator` — report `Spliterator.IMMUTABLE` from
   their `characteristics()` method. This is inconsistent with their
   actual behavior: each one snapshots `set.size()` at construction time
   and throws `ConcurrentModificationException` from `tryAdvance` /
   `forEachRemaining` when the underlying collection is structurally
   modified during traversal.
   
   The Javadoc for `Spliterator.IMMUTABLE` states that an immutable
   spliterator's element source "cannot be structurally modified".
   Reporting `IMMUTABLE` while detecting and reporting structural
   modification is a contract violation and can mislead stream pipelines
   or downstream callers that inspect characteristics.
   
   ### Related issue: NONNULL not enforced
   
   The same spliterators also report `NONNULL`, but the backing map and
   set implementations (`FastHashMap`, `FastHashSet`, `HashCommonMap`,
   `HashCommonSet`) accept `null` keys and values without complaint.
   While none of the current internal callers pass `null`, the interface
   contract was not documented and not enforced, so the `NONNULL`
   characteristic was technically also unsubstantiated.
   
   ### Proposed fix
   
   - Drop `IMMUTABLE` from `characteristics()` in the four spliterators.
   - Document on `JenaMap`, `JenaMapIndexed`, `JenaSet`,
     `JenaSetHashOptimized`, and `JenaSetIndexed` that null keys/values
     are not permitted.
   - Add `assert` checks on the write paths of the map/set
     implementations to catch violations in tests.
   
   ### Scope
   
   Internal to `jena-core` memory collections. No public API change; the
   affected interfaces are package-internal helpers used by the in-memory
   graph stores.
   
   ### Relevant output and stacktrace
   
   ```shell
   
   ```
   
   ### Are you interested in making a pull request?
   
   None


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