Skip to content

Commit e0192fb

Browse files
Adrian Coleadriancole
Adrian Cole
authored andcommitted
Updates to JDK 9
* updates circleci config (travis stays 1.8) * moves maven config to allow java 9 * fixes where retrolambda cannot backport lambdas * works around powermock incompatibility
1 parent 7a80b84 commit e0192fb

File tree

32 files changed

+531
-309
lines changed

32 files changed

+531
-309
lines changed

circle.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414

1515
# NOTE: Travis tests Elasticsearch and MySQL using Docker, and Kafka manually. We don't redundantly test them here
1616
machine:
17-
java:
18-
version: openjdk8
1917
environment:
18+
# Use java 9 here and 1.8 in travis (so that we test both)
19+
JAVA_HOME: /usr/lib/jvm/zulu-9-amd64
2020
# Quiet Maven invoker logs (Downloading... when running zipkin-server/src/it)
2121
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
2222

2323
dependencies:
2424
override:
25+
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
26+
- sudo apt-add-repository -y "deb http://repos.azulsystems.com/ubuntu stable main"
27+
- sudo apt-get -y update
28+
- sudo apt-get -y install zulu-9
2529
- sudo apt-get install xsltproc
2630
- ./circleci/go-offline.sh
2731
- ./mvnw frontend:install-node-and-npm frontend:npm -pl zipkin-ui

pom.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<junit.version>4.12</junit.version>
7171
<!-- to match powermock and spring testing -->
7272
<mockito.version>1.10.19</mockito.version>
73+
<powermock.version>2.0.0-beta.5</powermock.version>
7374
<assertj.version>3.8.0</assertj.version>
7475
<hamcrest.version>1.3</hamcrest.version>
7576
<okhttp.version>3.9.0</okhttp.version>
@@ -86,7 +87,7 @@
8687
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
8788
<maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
8889
<maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
89-
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
90+
<maven-enforcer-plugin.version>3.0.0-M1</maven-enforcer-plugin.version>
9091

9192
<!-- Catch common Java mistakes as compile-time errors -->
9293
<plexus-compiler-javac-errorprone.version>2.8.2</plexus-compiler-javac-errorprone.version>
@@ -321,6 +322,12 @@
321322
<version>${project.version}</version>
322323
</dependency>
323324

325+
<dependency>
326+
<groupId>javax.annotation</groupId>
327+
<artifactId>javax.annotation-api</artifactId>
328+
<version>1.3.1</version>
329+
</dependency>
330+
324331
<dependency>
325332
<groupId>org.jooq</groupId>
326333
<artifactId>jooq</artifactId>
@@ -497,7 +504,7 @@
497504
<pluginExecutionFilter>
498505
<groupId>org.apache.maven.plugins</groupId>
499506
<artifactId>maven-compiler-plugin</artifactId>
500-
<versionRange>[3.3,)</versionRange>
507+
<versionRange>[3.7,)</versionRange>
501508
<goals>
502509
<goal>compile</goal>
503510
<goal>testCompile</goal>
@@ -542,6 +549,8 @@
542549
<!-- Retrolambda will rewrite lambdas as Java 6 bytecode -->
543550
<source>1.8</source>
544551
<target>1.8</target>
552+
<!-- or die! com.sun.tools.javac.api.JavacTool -->
553+
<fork>true</fork>
545554
</configuration>
546555
<executions>
547556
<execution>
@@ -721,7 +730,7 @@
721730
<configuration>
722731
<rules>
723732
<requireJavaVersion>
724-
<version>[1.8,9)</version>
733+
<version>[1.8,10)</version>
725734
</requireJavaVersion>
726735
</rules>
727736
</configuration>

zipkin-autoconfigure/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
<properties>
3131
<main.basedir>${project.basedir}/..</main.basedir>
32+
<main.java.version>1.8</main.java.version>
33+
<main.signature.artifact>java18</main.signature.artifact>
3234
</properties>
3335

3436
<modules>
@@ -58,4 +60,19 @@
5860
<scope>test</scope>
5961
</dependency>
6062
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<!-- disable retrolambda as zipkin-server is language level 1.8 -->
67+
<plugin>
68+
<groupId>net.orfjackal.retrolambda</groupId>
69+
<artifactId>retrolambda-maven-plugin</artifactId>
70+
<executions>
71+
<execution>
72+
<phase>none</phase>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
</plugins>
77+
</build>
6178
</project>

zipkin-autoconfigure/storage-mysql/pom.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
<properties>
3030
<main.basedir>${project.basedir}/../..</main.basedir>
31-
<main.java.version>1.8</main.java.version>
32-
<main.signature.artifact>java18</main.signature.artifact>
3331
</properties>
3432

3533
<dependencies>
@@ -55,19 +53,4 @@
5553
<optional>true</optional>
5654
</dependency>
5755
</dependencies>
58-
59-
<build>
60-
<plugins>
61-
<!-- disable retrolambda as jooq itself is language level is 1.8 -->
62-
<plugin>
63-
<groupId>net.orfjackal.retrolambda</groupId>
64-
<artifactId>retrolambda-maven-plugin</artifactId>
65-
<executions>
66-
<execution>
67-
<phase>none</phase>
68-
</execution>
69-
</executions>
70-
</plugin>
71-
</plugins>
72-
</build>
7356
</project>

zipkin-collector/kafka/src/main/java/zipkin/collector/kafka/KafkaCollector.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,13 @@ static final class LazyStreams extends LazyCloseable<ExecutorService> {
217217
}
218218

219219
Runnable guardFailures(final Runnable delegate) {
220-
return () -> {
221-
try {
222-
delegate.run();
223-
} catch (RuntimeException e) {
224-
failure.set(CheckResult.failed(e));
220+
return new Runnable() {
221+
@Override public void run() {
222+
try {
223+
delegate.run();
224+
} catch (RuntimeException e) {
225+
failure.set(CheckResult.failed(e));
226+
}
225227
}
226228
};
227229
}

zipkin-collector/kafka10/src/main/java/zipkin/collector/kafka10/KafkaCollector.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,18 @@ static final class LazyKafkaWorkers extends LazyCloseable<ExecutorService> {
190190
}
191191

192192
Runnable guardFailures(final Runnable delegate) {
193-
return () -> {
194-
try {
195-
delegate.run();
196-
} catch (InterruptException e) {
197-
LOG.info("Kafka collector worker was interrupted. This is expected during shutdown.", e);
198-
failure.set(CheckResult.failed(e));
199-
} catch(RuntimeException e) {
200-
LOG.error("Kafka collector worker exited with exception.", e);
201-
failure.set(CheckResult.failed(e));
193+
return new Runnable() {
194+
@Override public void run() {
195+
try {
196+
delegate.run();
197+
} catch (InterruptException e) {
198+
LOG.info("Kafka collector worker was interrupted. This is expected during shutdown.",
199+
e);
200+
failure.set(CheckResult.failed(e));
201+
} catch (RuntimeException e) {
202+
LOG.error("Kafka collector worker exited with exception.", e);
203+
failure.set(CheckResult.failed(e));
204+
}
202205
}
203206
};
204207
}

zipkin-collector/scribe/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,19 @@
102102
<scope>test</scope>
103103
</dependency>
104104
</dependencies>
105+
106+
<build>
107+
<plugins>
108+
<!-- disable retrolambda as swift-service is language level 1.8 -->
109+
<plugin>
110+
<groupId>net.orfjackal.retrolambda</groupId>
111+
<artifactId>retrolambda-maven-plugin</artifactId>
112+
<executions>
113+
<execution>
114+
<phase>none</phase>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
</plugins>
119+
</build>
105120
</project>

zipkin-collector/scribe/src/main/java/zipkin/collector/scribe/ScribeSpanConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class ScribeSpanConsumer implements Scribe {
3232
final CollectorMetrics metrics;
3333
final String category;
3434

35-
public ScribeSpanConsumer(ScribeCollector.Builder builder) {
35+
ScribeSpanConsumer(ScribeCollector.Builder builder) {
3636
this.collector = builder.delegate.build();
3737
this.metrics = builder.metrics;
3838
this.category = builder.category;

zipkin-storage/cassandra/src/main/java/zipkin/storage/cassandra/CassandraSpanStore.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.datastax.driver.core.Session;
2222
import com.datastax.driver.core.querybuilder.QueryBuilder;
2323
import com.google.common.base.Function;
24+
import com.google.common.base.Predicate;
2425
import com.google.common.collect.ContiguousSet;
2526
import com.google.common.collect.FluentIterable;
2627
import com.google.common.collect.ImmutableList;
@@ -168,12 +169,14 @@ public final class CassandraSpanStore implements GuavaSpanStore {
168169
.orderBy(QueryBuilder.desc("ts")));
169170
}
170171

171-
traceIdToTimestamp = input -> {
172-
Map<Long, Long> result = new LinkedHashMap<>();
173-
for (Row row : input) {
174-
result.put(row.getLong("trace_id"), timestampCodec.deserialize(row, "ts"));
172+
traceIdToTimestamp = new Function<ResultSet, Map<Long, Long>>() {
173+
@Override public Map<Long, Long> apply(ResultSet input) {
174+
Map<Long, Long> result = new LinkedHashMap<>();
175+
for (Row row : input) {
176+
result.put(row.getLong("trace_id"), timestampCodec.deserialize(row, "ts"));
177+
}
178+
return result;
175179
}
176-
return result;
177180
};
178181
}
179182

@@ -239,7 +242,11 @@ public ListenableFuture<List<List<Span>>> apply(@Nullable Set<Long> traceIds) {
239242
@Override public List<List<Span>> apply(@Nullable List<Span> input) {
240243
// Indexes only contain Span.traceId, so our matches are imprecise on Span.traceIdHigh
241244
return FluentIterable.from(GroupByTraceId.apply(input, strictTraceId, true))
242-
.filter(trace -> trace.get(0).traceIdHigh == 0 || request.test(trace))
245+
.filter(new Predicate<List<Span>>() {
246+
@Override public boolean apply(List<Span> trace) {
247+
return trace.get(0).traceIdHigh == 0 || request.test(trace);
248+
}
249+
})
243250
.toList();
244251
}
245252
});
@@ -292,6 +299,10 @@ enum AdjustTrace implements Function<Collection<Span>, List<Span>> {
292299
List<Span> result = CorrectForClockSkew.apply(MergeById.apply(input));
293300
return result.isEmpty() ? null : result;
294301
}
302+
303+
@Override public String toString(){
304+
return "AdjustTrace";
305+
}
295306
}
296307

297308
@Override public ListenableFuture<List<String>> getServiceNames() {
@@ -363,6 +374,10 @@ enum ConvertDependenciesResponse implements Function<ResultSet, List<DependencyL
363374
}
364375
return DependencyLinker.merge(unmerged.build());
365376
}
377+
378+
@Override public String toString(){
379+
return "MergeDependencies";
380+
}
366381
}
367382

368383
/**

zipkin-storage/cassandra/src/main/java/zipkin/storage/cassandra/CassandraUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ enum KeySet implements Function<Map<Object, ?>, Set<Object>> {
122122
@Override public Set<Object> apply(@Nullable Map<Object, ?> input) {
123123
return input.keySet();
124124
}
125+
126+
@Override public String toString(){
127+
return "Map::keySet";
128+
}
125129
}
126130

127131
static Function<List<Map<Long, Long>>, Set<Long>> intersectKeySets() {
@@ -138,5 +142,9 @@ enum IntersectKeySets implements Function<List<Map<Object, ?>>, Set<Object>> {
138142
}
139143
return traceIds;
140144
}
145+
146+
@Override public String toString(){
147+
return "IntersectKeySets";
148+
}
141149
}
142150
}

zipkin-storage/elasticsearch-http/src/main/java/zipkin/storage/elasticsearch/http/LegacyElasticsearchHttpSpanStore.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ final class LegacyElasticsearchHttpSpanStore implements AsyncSpanStore {
5353
static final String SERVICE_SPAN = "servicespan";
5454
/** To not produce unnecessarily long queries, we don't look back further than first ES support */
5555
static final long EARLIEST_MS = 1456790400000L; // March 2016
56-
static final HttpCall.BodyConverter<List<String>>
57-
KEYS = b -> collectValuesNamed(JsonReader.of(b), "key");
56+
static final HttpCall.BodyConverter<List<String>> KEYS = new BodyConverter<List<String>>() {
57+
@Override public List<String> convert(BufferedSource b) throws IOException {
58+
return collectValuesNamed(JsonReader.of(b), "key");
59+
}
60+
};
5861
static final BodyConverter<List<Span>> SPANS =
5962
SearchResultConverter.create(LegacyJsonAdapters.SPAN_ADAPTER);
6063
static final BodyConverter<List<Span>> NULLABLE_SPANS =

zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/BodyConverters.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@
2626
import static zipkin2.elasticsearch.internal.JsonReaders.collectValuesNamed;
2727

2828
public final class BodyConverters {
29-
static final HttpCall.BodyConverter<List<String>>
30-
KEYS = b -> collectValuesNamed(JsonReader.of(b), "key");
29+
static final HttpCall.BodyConverter<Object> NULL = new HttpCall.BodyConverter<Object>() {
30+
@Override public Object convert(BufferedSource content) throws IOException {
31+
return null;
32+
}
33+
};
34+
static final HttpCall.BodyConverter<List<String>> KEYS =
35+
new HttpCall.BodyConverter<List<String>>() {
36+
@Override public List<String> convert(BufferedSource b) throws IOException {
37+
return collectValuesNamed(JsonReader.of(b), "key");
38+
}
39+
};
3140
static final HttpCall.BodyConverter<List<Span>> SPANS =
3241
SearchResultConverter.create(JsonAdapters.SPAN_ADAPTER);
3342
static final HttpCall.BodyConverter<List<DependencyLink>> DEPENDENCY_LINKS =

zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchSpanStore.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package zipkin2.elasticsearch;
1515

16+
import java.io.IOException;
1617
import java.util.ArrayList;
1718
import java.util.Collection;
1819
import java.util.Collections;
@@ -22,12 +23,14 @@
2223
import java.util.List;
2324
import java.util.Locale;
2425
import java.util.Map;
26+
import okio.BufferedSource;
2527
import zipkin2.Call;
2628
import zipkin2.DependencyLink;
2729
import zipkin2.Span;
2830
import zipkin2.elasticsearch.internal.IndexNameFormatter;
2931
import zipkin2.elasticsearch.internal.client.Aggregation;
3032
import zipkin2.elasticsearch.internal.client.HttpCall;
33+
import zipkin2.elasticsearch.internal.client.HttpCall.BodyConverter;
3134
import zipkin2.elasticsearch.internal.client.SearchCallFactory;
3235
import zipkin2.elasticsearch.internal.client.SearchRequest;
3336
import zipkin2.storage.QueryRequest;
@@ -102,25 +105,29 @@ final class ElasticsearchSpanStore implements SpanStore {
102105
HttpCall<List<String>> traceIdsCall = search.newCall(esRequest, BodyConverters.KEYS);
103106

104107
// When we receive span results, we need to group them by trace ID
105-
HttpCall.BodyConverter<List<List<Span>>> converter = content -> {
106-
HttpCall.BodyConverter<List<Span>> input = BodyConverters.SPANS;
107-
List<List<Span>> traces = groupByTraceId(input.convert(content), strictTraceId);
108-
109-
// Due to tokenization of the trace ID, our matches are imprecise on Span.traceIdHigh
110-
for (Iterator<List<Span>> trace = traces.iterator(); trace.hasNext(); ) {
111-
List<Span> next = trace.next();
112-
if (next.get(0).traceId().length() > 16 && !request.test(next)) {
113-
trace.remove();
108+
BodyConverter<List<List<Span>>> converter = new BodyConverter<List<List<Span>>>() {
109+
@Override public List<List<Span>> convert(BufferedSource content) throws IOException {
110+
List<Span> input = BodyConverters.SPANS.convert(content);
111+
List<List<Span>> traces = groupByTraceId(input, strictTraceId);
112+
113+
// Due to tokenization of the trace ID, our matches are imprecise on Span.traceIdHigh
114+
for (Iterator<List<Span>> trace = traces.iterator(); trace.hasNext(); ) {
115+
List<Span> next = trace.next();
116+
if (next.get(0).traceId().length() > 16 && !request.test(next)) {
117+
trace.remove();
118+
}
119+
}
120+
return traces;
114121
}
115-
}
116-
return traces;
117-
};
122+
};
118123

119-
return traceIdsCall.flatMap(input -> {
120-
if (input.isEmpty()) return Call.emptyList();
124+
return traceIdsCall.flatMap(new Call.FlatMapper<List<String>, List<List<Span>>>() {
125+
@Override public Call<List<List<Span>>> map(List<String> input) {
126+
if (input.isEmpty()) return Call.emptyList();
121127

122-
SearchRequest getTraces = SearchRequest.create(indices).terms("traceId", input);
123-
return search.newCall(getTraces, converter);
128+
SearchRequest getTraces = SearchRequest.create(indices).terms("traceId", input);
129+
return search.newCall(getTraces, converter);
130+
}
124131
});
125132
}
126133

0 commit comments

Comments
 (0)