Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit d522f90

Browse files
authored
Merge pull request #15 from sebright/remove-core-dependencies
Removes dependency on guava from census-core.
2 parents 5607abd + b84a013 commit d522f90

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

BUILD

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
java_library(
1616
name = "census-core",
1717
srcs = glob(["core/java/com/google/census/*.java"]),
18-
deps = [
19-
"@guava//jar",
20-
"@jsr305//jar",
21-
],
18+
deps = ["@jsr305//jar"],
2219
)
2320

2421
java_library(
@@ -27,7 +24,6 @@ java_library(
2724
deps = [
2825
":census-core",
2926
"//proto:census_context-proto-java",
30-
"@guava//jar",
3127
"@jsr305//jar",
3228
"@protobuf//jar",
3329
],

core/java/com/google/census/MetricMap.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313

1414
package com.google.census;
1515

16-
import com.google.common.collect.UnmodifiableIterator;
17-
1816
import java.util.ArrayList;
17+
import java.util.Iterator;
1918

2019
/**
2120
* A map from Census metric names to metric values.
@@ -59,11 +58,12 @@ public int size() {
5958
}
6059

6160
/**
62-
* Returns an {@link UnmodifiableIterator} over the name/value mappings in this {@link MetricMap}.
61+
* Returns an {@link Iterator} over the name/value mappings in this {@link MetricMap}. The
62+
* {@code Iterator} does not support {@link Iterator#remove()}.
6363
*/
6464
@Override
65-
public UnmodifiableIterator<Metric> iterator() {
66-
return new Iterator();
65+
public Iterator<Metric> iterator() {
66+
return new MetricMapIterator();
6767
}
6868

6969
private final ArrayList<Metric> metrics;
@@ -113,8 +113,8 @@ private Builder() {
113113
}
114114
}
115115

116-
// Provides an UnmodifiableIterator over this instance's metrics.
117-
private class Iterator extends UnmodifiableIterator<Metric> {
116+
// Provides an unmodifiable Iterator over this instance's metrics.
117+
private class MetricMapIterator implements Iterator<Metric> {
118118
@Override public boolean hasNext() {
119119
return position < length;
120120
}
@@ -123,6 +123,11 @@ private class Iterator extends UnmodifiableIterator<Metric> {
123123
return metrics.get(position++);
124124
}
125125

126+
@Override
127+
public void remove() {
128+
throw new UnsupportedOperationException();
129+
}
130+
126131
private final int length = metrics.size();
127132
private int position = 0;
128133
}

core/java/com/google/census/RpcConstants.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
package com.google.census;
1515

16-
import com.google.common.annotations.VisibleForTesting;
17-
1816
/**
1917
* Census constants for collecting rpc stats.
2018
*/
@@ -38,7 +36,8 @@ public final class RpcConstants {
3836
public static final MetricName RPC_SERVER_BYTES_SENT = new MetricName("/rpc/server/bytes_sent");
3937
public static final MetricName RPC_SERVER_LATENCY = new MetricName("/rpc/server/latency");
4038

41-
@VisibleForTesting RpcConstants() {
39+
//Visible for testing
40+
RpcConstants() {
4241
throw new AssertionError();
4342
}
4443
}

0 commit comments

Comments
 (0)