Skip to content

[grid] Bundle Redis-backed SessionMap by default#17441

Open
VietND96 wants to merge 1 commit into
trunkfrom
redis-backed-sessionsmap
Open

[grid] Bundle Redis-backed SessionMap by default#17441
VietND96 wants to merge 1 commit into
trunkfrom
redis-backed-sessionsmap

Conversation

@VietND96
Copy link
Copy Markdown
Member

🔗 Related Issues

💥 What does this PR do?

  • Redis-backed SessionMap is available out of the box with no extra configuration. selenium-session-map-redis was not bundled in selenium-server.jar by default, requiring users to manually manage it on the classpath - unlike distributor/redis, which has been built-in since [grid] Add Distributor Redis-backed implementation as built-in support #17396. Generic is Redis-backed support as default cross components.
  • Bug fix: null startKey in RedisBackedSessionMap.get()
  • Increase test coverage (RedisBackedSessionMapTest.java)

🔧 Implementation Notes

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • What was generated:
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • Bug fix (backwards compatible)
  • New feature (non-breaking change which adds functionality and tests!)
  • Breaking change (fix or feature that would cause existing functionality to change)

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
@selenium-ci selenium-ci added B-grid Everything grid and server related C-java Java Bindings B-build Includes scripting, bazel and CI integrations labels May 12, 2026
@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Bundle Redis-backed SessionMap by default and add configuration support

✨ Enhancement 🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Bundle Redis-backed SessionMap in selenium-server.jar by default
• Add configuration flags for sessions scheme and implementation
• Fix null startKey handling in RedisBackedSessionMap.get()
• Expand test coverage with new SessionMapFlags and edge case tests
Diagram
flowchart LR
  A["SessionMapFlags"] -->|"Add scheme & implementation params"| B["Configuration Support"]
  C["RedisBackedSessionMap"] -->|"Fix null startKey bug"| D["Null Safety"]
  E["BUILD.bazel"] -->|"Add redis dependency"| F["Default Bundling"]
  B --> G["Enhanced SessionMap"]
  D --> G
  F --> G
  H["New Tests"] -->|"SessionMapFlags & edge cases"| G
Loading

Grey Divider

File Changes

1. java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapFlags.java ✨ Enhancement +15/-0

Add sessions scheme and implementation configuration parameters

java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapFlags.java


2. java/src/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMap.java 🐞 Bug fix +1/-1

Fix null pointer exception when startKey is missing

java/src/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMap.java


3. java/test/org/openqa/selenium/grid/sessionmap/config/SessionMapFlagsTest.java 🧪 Tests +69/-0

New test suite for SessionMapFlags configuration parameters

java/test/org/openqa/selenium/grid/sessionmap/config/SessionMapFlagsTest.java


View more (6)
4. java/test/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMapTest.java 🧪 Tests +100/-0

Expand test coverage with edge cases and null handling

java/test/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMapTest.java


5. java/src/org/openqa/selenium/grid/BUILD.bazel ⚙️ Configuration changes +1/-0

Add redis sessionmap to selenium_server runtime dependencies

java/src/org/openqa/selenium/grid/BUILD.bazel


6. java/src/org/openqa/selenium/grid/commands/sessionmaps.txt 📝 Documentation +6/-6

Update documentation to reflect default Redis bundling

java/src/org/openqa/selenium/grid/commands/sessionmaps.txt


7. java/src/org/openqa/selenium/grid/sessionmap/config/BUILD.bazel ⚙️ Configuration changes +1/-0

Expose config package visibility for test access

java/src/org/openqa/selenium/grid/sessionmap/config/BUILD.bazel


8. java/test/org/openqa/selenium/grid/sessionmap/config/BUILD.bazel ⚙️ Configuration changes +15/-0

Create new test suite build configuration

java/test/org/openqa/selenium/grid/sessionmap/config/BUILD.bazel


9. java/test/org/openqa/selenium/grid/sessionmap/redis/BUILD.bazel ⚙️ Configuration changes +3/-0

Add test dependencies for config and event bus

java/test/org/openqa/selenium/grid/sessionmap/redis/BUILD.bazel


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 12, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0)

Context used

Grey Divider


Remediation recommended

1. --sessions-scheme unvalidated input 📘 Rule violation ☼ Reliability
Description
The newly added --sessions-scheme flag accepts arbitrary user input but there is no early
validation to ensure it is a valid URI scheme, which can lead to confusing failures when building
the SessionMap URI. This violates the requirement to validate external/config-derived inputs early
with clear, deterministic exceptions.
Code

java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapFlags.java[R52-56]

+  @Parameter(
+      names = "--sessions-scheme",
+      description = "URI scheme for the session map server (e.g. \"redis\", \"http\").")
+  @ConfigValue(section = "sessions", name = "scheme", example = "\"redis\"")
+  private String sessionServerScheme;
Evidence
PR adds a new CLI/config entry point --sessions-scheme without any validation logic. The value is
later consumed to construct a URI in SessionMapOptions.getSessionMapUri(), where invalid schemes
can cause failures that are not clearly attributed to the invalid sessions.scheme input.

java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapFlags.java[52-56]
java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapOptions.java[40-82]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`--sessions-scheme` is a new external/config-derived input but is not validated early. Invalid values can surface later during URI construction with an error that does not clearly identify `sessions.scheme` as the problem.

## Issue Context
The flag populates `sessions.scheme`, which is later used to construct a `URI` for the SessionMap server.

## Fix Focus Areas
- java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapFlags.java[52-56]
- java/src/org/openqa/selenium/grid/sessionmap/config/SessionMapOptions.java[40-82]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@diemol
Copy link
Copy Markdown
Member

diemol commented May 12, 2026

Does this mean we're increasing the size of the jar file? What is the size difference since we have added this to the distributor as well? We should pay attention to that so we don't bloat the server.

@VietND96
Copy link
Copy Markdown
Member Author

@diemol. Yes, the diff is 42.3 MB...51M. The same size applies to cross components (Distributor, SessionMap, and later SessionQueue). Do you think it's worth it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-grid Everything grid and server related C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants