Skip to content

Conversation

@mykaul
Copy link

@mykaul mykaul commented Jan 1, 2026

In general, the problem is that the loop unconditionally assumes that propsToMatch has an even number of elements and indexes i + 1 without verifying this. The robust fix is to either (a) validate upfront that propsToMatch.length is even and fail fast with a clear message if not, or (b) adjust the loop bound so that i + 1 is always within range. Both approaches prevent an ArrayIndexOutOfBoundsException.

The best way here, without changing existing functionality for valid inputs, is to add an explicit check at the start of assertThatContainsProperties ensuring that propsToMatch.length is even. If it is not, we can throw an IllegalArgumentException with a helpful message. This preserves the current behavior for correct usages (even length), while turning undefined/out-of-bounds behavior into a clear, deterministic failure. The loop body itself can then stay as-is. All changes are confined to assertThatContainsProperties in core/src/test/java/com/datastax/dse/driver/internal/core/graph/GraphTestUtils.java; no imports or additional methods are required.

Concretely:

  • Inside assertThatContainsProperties, before the for loop, add:
if ((propsToMatch.length % 2) != 0) {
  throw new IllegalArgumentException(
      "propsToMatch must contain an even number of elements (key/value pairs)");
}
  • Leave the loop and method signature unchanged.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@dkropachev
Copy link

@mykaul , it is DSE code, probably we better if drop it completely.

@mykaul
Copy link
Author

mykaul commented Jan 1, 2026

@mykaul , it is DSE code, probably we better if drop it completely.

@dkropachev - I'm completely fine with that, and in favor, but we need to make a decision about dropping Graph support (also in other drivers).

@dkropachev dkropachev marked this pull request as ready for review January 1, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants