Skip to content

Commit 5a8b480

Browse files
committed
Remove guava dep from logging package
1 parent 61f35cf commit 5a8b480

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

java/client/src/org/openqa/selenium/logging/BUCK

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ java_library(name = 'logging',
2525
'//java/client/src/org/openqa/selenium:beta',
2626
'//java/client/src/org/openqa/selenium:exceptions',
2727
'//java/client/src/org/openqa/selenium/json:json',
28-
'//third_party/java/guava:guava',
2928
],
3029
visibility = [
31-
'//java/client/src/org/openqa/selenium:selenium'
30+
'//java/client/src/org/openqa/selenium:selenium',
3231
],
3332
)

java/client/src/org/openqa/selenium/logging/CompositeLocalLogs.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import com.google.common.collect.Sets;
21-
2220
import java.util.Set;
21+
import java.util.TreeSet;
2322

2423
/**
2524
* LocalLogs implementation that holds two other local logs.
@@ -50,7 +49,10 @@ public LogEntries get(String logType) {
5049
}
5150

5251
public Set<String> getAvailableLogTypes() {
53-
return Sets.union(predefinedTypeLogger.getAvailableLogTypes(), allTypesLogger.getAvailableLogTypes());
52+
TreeSet<String> toReturn = new TreeSet<>();
53+
toReturn.addAll(predefinedTypeLogger.getAvailableLogTypes());
54+
toReturn.addAll(allTypesLogger.getAvailableLogTypes());
55+
return toReturn;
5456
}
5557

5658
@Override

java/client/src/org/openqa/selenium/logging/HandlerBasedLocalLogs.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import com.google.common.collect.ImmutableSet;
21-
2220
import java.util.Collection;
2321
import java.util.Collections;
2422
import java.util.Set;
@@ -46,7 +44,7 @@ public LogEntries get(String logType) {
4644
}
4745

4846
public Set<String> getAvailableLogTypes() {
49-
return ImmutableSet.of(LogType.CLIENT);
47+
return Collections.singleton(LogType.CLIENT);
5048
}
5149

5250
public void addEntry(String logType, LogEntry entry) {

java/client/src/org/openqa/selenium/logging/LogCombiner.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import com.google.common.collect.Iterables;
21-
22-
import java.util.Arrays;
20+
import java.util.Collection;
2321
import java.util.Comparator;
22+
import java.util.stream.Collectors;
23+
import java.util.stream.Stream;
2424

2525
public class LogCombiner {
2626
private static final Comparator<LogEntry> LOG_ENTRY_TIMESTAMP_COMPARATOR =
2727
Comparator.comparingLong(LogEntry::getTimestamp);
2828

2929
public static LogEntries combine(LogEntries... entries) {
30+
3031
return new LogEntries(
31-
Iterables.mergeSorted(Arrays.asList(entries), LOG_ENTRY_TIMESTAMP_COMPARATOR));
32+
Stream.of(entries)
33+
.map(LogEntries::getAll)
34+
.flatMap(Collection::stream)
35+
.sorted(LOG_ENTRY_TIMESTAMP_COMPARATOR)
36+
.collect(Collectors.toList()));
3237
}
3338
}

java/client/src/org/openqa/selenium/logging/profiler/HttpProfilerLogEntry.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
package org.openqa.selenium.logging.profiler;
1919

20-
import com.google.common.collect.ImmutableMap;
21-
2220
import org.openqa.selenium.json.Json;
2321

24-
import java.util.Map;
22+
import java.util.TreeMap;
2523

2624
public class HttpProfilerLogEntry extends ProfilerLogEntry {
2725

@@ -30,10 +28,10 @@ public HttpProfilerLogEntry(String commandName, boolean isStart) {
3028
}
3129

3230
private static String constructMessage(EventType eventType, String commandName, boolean isStart) {
33-
Map<String, ?> map = ImmutableMap.of(
34-
"event", eventType.toString(),
35-
"command", commandName,
36-
"startorend", isStart ? "start" : "end");
31+
TreeMap<Object, Object> map = new TreeMap<>();
32+
map.put("event", eventType.toString());
33+
map.put("command", commandName);
34+
map.put("startorend", isStart ? "start" : "end");
3735
return new Json().toJson(map);
3836
}
3937

0 commit comments

Comments
 (0)