Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/bidi/log/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_jvm_external//:defs.bzl", "artifact")
load("//java:defs.bzl", "java_library")

java_library(
Expand All @@ -19,5 +20,6 @@ java_library(
"//java/src/org/openqa/selenium/bidi/script",
"//java/src/org/openqa/selenium/json",
"//java/src/org/openqa/selenium/remote/http",
artifact("org.jspecify:jspecify"),
],
)
8 changes: 5 additions & 3 deletions java/src/org/openqa/selenium/bidi/log/BaseLogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

package org.openqa.selenium.bidi.log;

import org.jspecify.annotations.Nullable;
import org.openqa.selenium.bidi.script.Source;

// @see <a
// href="https://w3c.github.io/webdriver-bidi/#types-log-logentry">https://w3c.github.io/webdriver-bidi/#types-log-logentry</a>
public class BaseLogEntry {

private final LogLevel level;
private Source source;
private final Source source;
private final String text;
private final long timestamp;
private final StackTrace stackTrace;
@Nullable private final StackTrace stackTrace;

public LogLevel getLevel() {
return level;
Expand All @@ -41,6 +42,7 @@ public long getTimestamp() {
return timestamp;
}

@Nullable
public StackTrace getStackTrace() {
return stackTrace;
}
Expand All @@ -50,7 +52,7 @@ public Source getSource() {
}

public BaseLogEntry(
LogLevel level, Source source, String text, long timestamp, StackTrace stackTrace) {
LogLevel level, Source source, String text, long timestamp, @Nullable StackTrace stackTrace) {
this.level = level;
this.source = source;
this.text = text;
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/bidi/log/ConsoleLogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.bidi.script.RemoteValue;
import org.openqa.selenium.bidi.script.Source;
import org.openqa.selenium.json.JsonInput;
Expand All @@ -42,7 +43,7 @@ public ConsoleLogEntry(
String type,
String method,
List<RemoteValue> args,
StackTrace stackTrace) {
@Nullable StackTrace stackTrace) {
super(level, source, text, timestamp, type, stackTrace);
this.method = method;
this.args = args;
Expand Down
7 changes: 5 additions & 2 deletions java/src/org/openqa/selenium/bidi/log/GenericLogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.Map;
import java.util.TreeMap;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.bidi.script.Source;
import org.openqa.selenium.json.JsonInput;

Expand All @@ -36,7 +37,7 @@ public GenericLogEntry(
String text,
long timestamp,
String type,
StackTrace stackTrace) {
@Nullable StackTrace stackTrace) {
super(level, source, text, timestamp, stackTrace);
this.type = type;
}
Expand Down Expand Up @@ -97,7 +98,9 @@ private Map<String, Object> toJson() {
toReturn.put("level", super.getLevel());
toReturn.put("text", super.getText());
toReturn.put("timestamp", super.getTimestamp());
toReturn.put("stackTrace", super.getStackTrace());
if (getStackTrace() != null) {
toReturn.put("stackTrace", getStackTrace());
}

return unmodifiableMap(toReturn);
}
Expand Down
7 changes: 5 additions & 2 deletions java/src/org/openqa/selenium/bidi/log/JavascriptLogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.Map;
import java.util.TreeMap;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.bidi.script.Source;
import org.openqa.selenium.json.JsonInput;

Expand All @@ -36,7 +37,7 @@ public JavascriptLogEntry(
String text,
long timestamp,
String type,
StackTrace stackTrace) {
@Nullable StackTrace stackTrace) {
super(level, source, text, timestamp, "javascript", stackTrace);
this.type = "javascript";
}
Expand Down Expand Up @@ -97,7 +98,9 @@ private Map<String, Object> toJson() {
toReturn.put("level", super.getLevel());
toReturn.put("text", super.getText());
toReturn.put("timestamp", super.getTimestamp());
toReturn.put("stackTrace", super.getStackTrace());
if (getStackTrace() != null) {
toReturn.put("stackTrace", getStackTrace());
}

return unmodifiableMap(toReturn);
}
Expand Down
21 changes: 21 additions & 0 deletions java/src/org/openqa/selenium/bidi/log/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

@NullMarked
package org.openqa.selenium.bidi.log;

import org.jspecify.annotations.NullMarked;
6 changes: 3 additions & 3 deletions java/test/org/openqa/selenium/bidi/log/LogInspectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.openqa.selenium.bidi.log;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.assertj.core.api.AssertionsForClassTypes.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;

import java.util.HashSet;
import java.util.Set;
Expand Down
Loading