Skip to content

Find Element Data by its key whatever the case - #167

Merged
jwrosewell merged 3 commits into
rcfrom
fix/element-data-key-case
Nov 16, 2026
Merged

jwrosewell merged 3 commits into
rcfrom
fix/element-data-key-case

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Element Data keys are now compared ignoring case, so flowData.get("Device") finds the Element Data stored under device, and adding Element Data under a key that differs only in case finds the Element Data already there. Until now the lookup compared keys exactly, so flowData.get("Device") threw NoSuchElementException.

What the specification says

access-to-results.md lines 5 to 11 at b3b2c0dd:

Where string keys are used, the following rules apply:

  • Strings SHOULD only contain alphanumeric characters, full stop or hyphen.
  • Some 51Degrees Properties also use the ‘/’ character. No new Properties will be added with this character, but it will need to be accommodated.
  • Lower-case SHOULD be used.
  • String comparisons MUST be case insensitive.

Lines 19 and 20 say "It MUST be possible to get Element Data by supplying the string key for the element."

What was different on rc

Flow Data keeps its Element Data in the map TypedKeyMapBuilder makes, and its findWithPrevious, which every lookup, put, containsKey and removal goes through, compared each key's name with equals. Property names already ignore case, through each Element Data's own map.

What changed

f92ce9c8. findWithPrevious compares names with equalsIgnoreCase, in both of its comparisons. Both kinds of map the builder makes, for a concurrent Pipeline and not, use it. A key keeps the spelling it was first stored under, and getKeys gives that spelling. equalsIgnoreCase compares character by character with no locale, so the result is the same under any default locale.

Before you upgrade

flowData.get(key), getOrAdd(key, ...) and the other ways of reaching Element Data by its key now find the Element Data whatever the case of the key. Code that stored two Element Data under keys differing only in case, which no 51Degrees element does, now gets one entry, the second write replacing the first value.

Tests

Tests first, 677e2ee5. New TypedKeyMapKeyCaseTests, run against both kinds of map, checks that a value stored under device is found as Device and DEVICE and that containsKey("Device") is true, that a second put under Device replaces the value and leaves one key, and that the key keeps the spelling first given. New in FlowDataTests, FlowData_AddDataString_GetDataStringOtherCase gets Element Data stored as device with Device and DEVICE, and FlowData_GetOrAddOtherCase_SameData expects getOrAdd("Device", ...) to return the Element Data already added as device.

Red 43698064380 ran the test commit on rc 30e8df6 plus a throwaway workflow on Ubuntu and Windows, Java 17. On both, all three TypedKeyMapKeyCaseTests and the two new FlowDataTests failed, with NoSuchElementException, "expected:<1> but was:<2>", "expected:<[device]> but was:<[DEVICE, device]>" and "expected same", while the other 39 FlowDataTests and the 19 tests in each of TypedKeyMapTestConcurrent and TypedKeyMapTestNonConcurrent passed. Green 43698075971 ran the head plus the same workflow, and on both systems TypedKeyMapKeyCaseTests passed 3 of 3, FlowDataTests 41 of 41, and each TypedKeyMapTest class 19 of 19.

Full build

Run 43916478929 built ed94d31 merged with rc 81e3d4a on nine configurations, Ubuntu x64 with Java 8, 11, 17 and 21, Ubuntu arm64 with Java 17, and Windows with Java 8, 11, 17 and 21. Configure and all nine Build and Test jobs passed, read from each job's log, and TypedKeyMapKeyCaseTests passed 3 of 3 in all nine jobs. Each of its ten Setting 'PullRequestSha' lines names ed94d31, and its Configure job printed "Left out 6 macOS entries". The run's last job, which only gathers the results, was still waiting for a runner when this was written.

What it releases

pipeline.core changes, so it and the packages that depend on it are released, each at its own next patch version.

Base branch

rc 81e3d4a is merged into the head, ed94d31, with a merge commit, with no conflict. #179 changes the same TypedKeyMapBuilder.java, so whichever merges second keeps one copy.

What remains

Nothing for this requirement in Java.

@jwrosewell
jwrosewell marked this pull request as ready for review November 16, 2026 21:47
@jwrosewell
jwrosewell merged commit 46115d7 into rc Nov 16, 2026
3 checks passed
@jwrosewell
jwrosewell deleted the fix/element-data-key-case branch November 16, 2026 21:47
jwrosewell added a commit that referenced this pull request Nov 16, 2026
@jwrosewell jwrosewell mentioned this pull request Nov 16, 2026
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.

1 participant