Skip to content

Conversation

@iampopovich
Copy link
Contributor

@iampopovich iampopovich commented Aug 15, 2025

User description

🔗 Related Issues

fixes #16181

💥 What does this PR do?

scope of properties changed to protected

  • httpClientFactory -> private to protected
  • additionalCommands -> private to protected

🔧 Implementation Notes

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

PR Type

Enhancement


Description

  • Changed visibility of two fields from private to protected

  • Enables subclass access to httpClientFactory and additionalCommands

  • Improves extensibility for custom implementations


Diagram Walkthrough

flowchart LR
  A["HttpCommandExecutor class"] --> B["httpClientFactory field"]
  A --> C["additionalCommands field"]
  B --> D["private → protected"]
  C --> E["private → protected"]
Loading

File Walkthrough

Relevant files
Enhancement
HttpCommandExecutor.java
Field visibility enhancement for extensibility                     

java/src/org/openqa/selenium/remote/HttpCommandExecutor.java

  • Changed httpClientFactory field visibility from private to protected
  • Changed additionalCommands field visibility from private to protected
+2/-2     

@selenium-ci selenium-ci added the C-java Java Bindings label Aug 15, 2025
@iampopovich iampopovich marked this pull request as ready for review August 15, 2025 13:48
@qodo-merge-pro
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

API Surface Change

Changing field visibility from private to protected expands the public API for inheritance and may lock in backward compatibility; confirm this is intentional and documented in release notes, and verify no unintended subclassing side effects occur.

protected final HttpClient.Factory httpClientFactory;
protected final Map<String, CommandInfo> additionalCommands;
Encapsulation Risk

Exposing mutable fields like additionalCommands to subclasses can allow state changes that affect thread-safety or invariants; consider providing protected accessors or defensive patterns if mutation must be controlled.

protected final Map<String, CommandInfo> additionalCommands;
protected CommandCodec<HttpRequest> commandCodec;

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Aug 15, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Learned
best practice
Preserve encapsulation with accessors

Changing fields from private to protected broadens access and risks unintended
mutation. Prefer keeping fields private and providing controlled, documented
accessors that return defensive copies or unmodifiable views.

java/src/org/openqa/selenium/remote/HttpCommandExecutor.java [50-51]

-protected final HttpClient.Factory httpClientFactory;
-protected final Map<String, CommandInfo> additionalCommands;
+private final HttpClient.Factory httpClientFactory;
+private final Map<String, CommandInfo> additionalCommands;
 
+protected final HttpClient.Factory getHttpClientFactory() {
+  return httpClientFactory;
+}
+
+protected final Map<String, CommandInfo> getAdditionalCommands() {
+  return Collections.unmodifiableMap(additionalCommands);
+}
+
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Avoid weakening encapsulation without safeguards; exposing internals should be accompanied by clear contracts or immutability to prevent misuse.

Low
  • Update

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@diemol diemol merged commit f227da9 into SeleniumHQ:trunk Aug 18, 2025
60 of 61 checks passed
This was referenced Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🚀 Feature]: Better Selenium and Appium java clients compatibility

3 participants