[java] for loop enhance and using of standard java 11 method writeString for tests #14889
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
This pull request includes several changes to improve the code by replacing the
Files.write
method with the more conciseFiles.writeString
method. Additionally, there is a minor refactor to simplify a loop structure.Codebase simplification:
java/src/org/openqa/selenium/grid/jmx/MBean.java
: Refactored a for loop to use enhanced for-loop syntax for better readability.Method replacement:
java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java
: ReplacedFiles.write
withFiles.writeString
to simplify writing string content to files.java/test/org/openqa/selenium/UploadTest.java
: Updated method to useFiles.writeString
for writing string content to temporary files.java/test/org/openqa/selenium/edge/EdgeOptionsTest.java
: Changed file writing method toFiles.writeString
for better readability and simplicity.java/test/org/openqa/selenium/environment/webserver/AppServerTestBase.java
: Simplified file writing by usingFiles.writeString
instead ofFiles.write
.Motivation and Context
I changed the method calls for writing strings to standard ones from Java 11 to include more standard solutions from the language library. I also replaced looping through the collection with an iterator for better code readability.
Types of changes
Checklist
PR Type
enhancement
Description
MBean.java
to use enhanced for-loop syntax for improved readability.Files.write
withFiles.writeString
across multiple files to simplify file writing operations.Changes walkthrough 📝
MBean.java
Refactor for loop to enhanced for-loop syntax
java/src/org/openqa/selenium/grid/jmx/MBean.java
DockerSessionFactory.java
Use Files.writeString for writing strings to files
java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java
Files.write
withFiles.writeString
.UploadTest.java
Simplify file writing with Files.writeString
java/test/org/openqa/selenium/UploadTest.java
Files.writeString
.EdgeOptionsTest.java
Update file writing to Files.writeString
java/test/org/openqa/selenium/edge/EdgeOptionsTest.java
Files.writeString
.AppServerTestBase.java
Use Files.writeString for temporary file creation
java/test/org/openqa/selenium/environment/webserver/AppServerTestBase.java
Files.write
withFiles.writeString
.NodeTest.java
Simplify file writing in NodeTest with Files.writeString
java/test/org/openqa/selenium/grid/node/NodeTest.java
Files.writeString
.ResourceHandlerTest.java
Refactor file operations to use Files.writeString
java/test/org/openqa/selenium/grid/web/ResourceHandlerTest.java
Files.write
withFiles.writeString
in tests.TestUtilities.java
Simplify file writing in TestUtilities
java/test/org/openqa/selenium/testing/TestUtilities.java
Files.writeString
.