[java] Enhance ScriptKey.toString() and mask script content in UnpinnedScriptKey#17159
Conversation
Review Summary by QodoAdd toString() override to ScriptKey for better debugging
WalkthroughsDescription• Adds toString() override to ScriptKey class • Returns the underlying identifier for improved debugging • Replaces unhelpful default Object.toString() output • Non-breaking change with no functional impact File Changes1. java/src/org/openqa/selenium/ScriptKey.java
|
Code Review by Qodo
1. ScriptKey.toString() untested
|
|
Many RBE CI tests are failing on this branch.. I haven't investigated if they are related to these changes. |
Review Summary by Qodo[java] Add toString() to ScriptKey and mask script content in UnpinnedScriptKey
WalkthroughsDescription• Add toString() to ScriptKey returning the identifier directly • Override toString() in UnpinnedScriptKey to prevent raw script exposure in logs • Add unit tests for both ScriptKey and UnpinnedScriptKey toString behavior File Changes1. java/src/org/openqa/selenium/ScriptKey.java
|
Code Review by Qodo
1. ScriptKey.toString() untested
|
Review Summary by Qodo[java] Add toString() to ScriptKey and mask script content in UnpinnedScriptKey
WalkthroughsDescription• Add toString() to ScriptKey returning the identifier string • Override toString() in UnpinnedScriptKey to avoid exposing raw script content in logs • Add unit tests for both ScriptKey and UnpinnedScriptKey toString behavior File Changes1. java/src/org/openqa/selenium/ScriptKey.java
|
Code Review by Qodo
1. ScriptKey.toString() untested
|
💥 What does this PR do?
Overrides
toString()inorg.openqa.selenium.ScriptKeyto return the underlying identifier instead of relying on the defaultObject.toString()implementation.Previously, logging or printing a
ScriptKeyinstance produced output such as:This output is not helpful for debugging. Since
ScriptKeyrepresents an identifier wrapper, its string representation should reflect that identifier directly.After this change, printing a
ScriptKeywill produce:Additionally,
UnpinnedScriptKeynow overridestoString()to prevent exposing the full JavaScript source in logs. SinceUnpinnedScriptKeyinternally stores the raw script as its identifier, returning it directly could result in large log output or unintended disclosure. The override ensures a safe, concise debug representation without leaking script content.This improves debugging clarity while avoiding potential log bloat or sensitive script exposure.
🔧 Implementation Notes
toString()inScriptKeyto return theidentifierfield.toString()inUnpinnedScriptKeyto avoid logging raw script content.equals()orhashCode().toJson()andfromJson()remains unaffected.💡 Additional Considerations
UnpinnedScriptKey.🔄 Types of changes