8000 fix: usage of Optional.orElseThrow after Map.put by artlomako · Pull Request #2145 · appium/java-client · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: usage of Optional.orElseThrow after Map.put #2145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ public KeyEvent withFlag(KeyEventFlag keyEventFlag) {
*/
public Map<String, Object> build() {
var map = new HashMap<String, Object>();
ofNullable(this.keyCode).map(x -> map.put("keycode", x)).orElseThrow(() -> new IllegalStateException(
Copy link
Contributor

Choose a reason for hiding this comment

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

@valfirst Could there be other places in the source like this one? I assume the issue may have been added during the recent refactoring

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, this is a regression issue, I've found 2 more similar occurrences, I'll open PR soon

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks. Lets address them all and publish a patch asap

Copy link
Contributor Author
@artlomako artlomako Mar 28, 2024

Choose a reason for hiding this comment

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

@mykola-mokhnach I believe I fixed them in my last commit

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've already addressed AndroidGeoLocation issues here: #2146

"The key code must be set"));
ofNullable(this.keyCode).ifPresentOrElse(x -> map.put("keycode", x), () -> {
throw new IllegalStateException("The key code must be set");
});
ofNullable(this.metaState).ifPresent(x -> map.put("metastate", x));
ofNullable(this.flags).ifPresent(x -> map.put("flags", x));
return Collections.unmodifiableMap(map);
Expand Down
Loading
0