Skip to content

Commit

Permalink
build: fixes bytecode level and updates build versions (#236)
Browse files Browse the repository at this point in the history
This fixes a problem where we weren't releasing jars with the right
bytecode level, due to a constant release=8. As we no longer can rely on
RetroLambda to rewrite code, I've had to port things to the appropriate
bytecode level manually. I also updated build deps that could be.

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Jan 6, 2024
1 parent 9fbb64d commit f195606
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 167 deletions.
9 changes: 3 additions & 6 deletions activemq-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
as the former uses javax.jms and latter jakarta.jms. It could be
better to make an activemq-client6 module. -->
<activemq.version>5.18.3</activemq.version>

<!-- CI should run the "release" profile during tests to ensure no 1.8
features are in use. -->
<!-- activemq is Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -67,7 +62,9 @@
<id>release</id>
<properties>
<!-- activemq is Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -77,7 +77,7 @@ public static final class Builder {
ActiveMQConnectionFactory connectionFactory;
String queue = "zipkin";
Encoding encoding = Encoding.JSON;
int messageMaxBytes = 500_000;
int messageMaxBytes = 500000;

public Builder connectionFactory(ActiveMQConnectionFactory connectionFactory) {
if (connectionFactory == null) throw new NullPointerException("connectionFactory == null");
Expand Down Expand Up @@ -159,9 +159,9 @@ public final ActiveMQSender build() {
@Override public CheckResult check() {
try {
lazyInit.get();
} catch (IOException | RuntimeException | Error e) {
Call.propagateIfFatal(e);
return CheckResult.failed(e);
} catch (Throwable t) {
Call.propagateIfFatal(t);
return CheckResult.failed(t);
}
return lazyInit.result.checkResult;
}
Expand Down Expand Up @@ -210,8 +210,9 @@ void send() throws IOException {
try {
send();
callback.onSuccess(null);
} catch (IOException | RuntimeException | Error e) {
callback.onError(e);
} catch (Throwable t) {
Call.propagateIfFatal(t);
callback.onError(t);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ String brokerURL() {
// mostly waiting for https://github.com/testcontainers/testcontainers-java/issues/3537
static final class ActiveMQContainer extends GenericContainer<ActiveMQContainer> {
ActiveMQContainer() {
super(parse("ghcr.io/openzipkin/zipkin-activemq:2.26.0"));
super(parse("ghcr.io/openzipkin/zipkin-activemq:2.27.0"));
if ("true".equals(System.getProperty("docker.skip"))) {
throw new TestAbortedException("${docker.skip} == true");
}
Expand Down
7 changes: 3 additions & 4 deletions amqp-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
<amqp-client.version>5.20.0</amqp-client.version>
<!-- Last pre-1.8 version -->
<old-amqp-client.version>4.12.0</old-amqp-client.version>

<!-- amqp-client 4.x is Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -97,7 +94,9 @@
<id>release</id>
<properties>
<!-- amqp-client 4.x is Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
3 changes: 2 additions & 1 deletion amqp-client/src/it/amqp_v4/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2023 The OpenZipkin Authors
Copyright 2016-2024 The OpenZipkin Authors
Licensed 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
Expand Down Expand Up @@ -30,6 +30,7 @@

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -36,7 +36,7 @@
* This sends (usually json v2) encoded spans to a RabbitMQ queue.
*
* <h3>Usage</h3>
*
* <p>
* This type is designed for {@link AsyncReporter.Builder#builder(Sender) the async reporter}.
*
* <p>Here's a simple configuration, configured for json:
Expand Down Expand Up @@ -87,7 +87,7 @@ public static final class Builder {
List<Address> addresses;
String queue = "zipkin";
Encoding encoding = Encoding.JSON;
int messageMaxBytes = 500_000;
int messageMaxBytes = 500000;

Builder(RabbitMQSender sender) {
connectionFactory = sender.connectionFactory.clone();
Expand Down Expand Up @@ -249,7 +249,9 @@ Connection get() {
Connection newConnection() {
try {
return connectionFactory.newConnection(addresses);
} catch (IOException | TimeoutException e) {
} catch (IOException e) {
throw new RuntimeException("Unable to establish connection to RabbitMQ server", e);
} catch (TimeoutException e) {
throw new RuntimeException("Unable to establish connection to RabbitMQ server", e);
}
}
Expand All @@ -261,7 +263,7 @@ Connection newConnection() {
closeCalled = true;
}

final ThreadLocal<Channel> CHANNEL = new ThreadLocal<>();
final ThreadLocal<Channel> CHANNEL = new ThreadLocal<Channel>();

/**
* In most circumstances there will only be one thread calling {@link #sendSpans(List)}, the
Expand Down Expand Up @@ -298,8 +300,9 @@ void publish() throws IOException {
try {
publish();
callback.onSuccess(null);
} catch (IOException | RuntimeException | Error e) {
callback.onError(e);
} catch (Throwable t) {
Call.propagateIfFatal(t);
callback.onError(t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int port() {
// mostly waiting for https://github.com/testcontainers/testcontainers-java/issues/3537
static final class RabbitMQContainer extends GenericContainer<RabbitMQContainer> {
RabbitMQContainer() {
super(parse("ghcr.io/openzipkin/zipkin-rabbitmq:2.26.0"));
super(parse("ghcr.io/openzipkin/zipkin-rabbitmq:2.27.0"));
if ("true".equals(System.getProperty("docker.skip"))) {
throw new TestAbortedException("${docker.skip} == true");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class KafkaSenderBenchmarks extends SenderBenchmarks {

static final class KafkaContainer extends GenericContainer<KafkaContainer> {
KafkaContainer() {
super(parse("ghcr.io/openzipkin/zipkin-kafka:2.26.0"));
super(parse("ghcr.io/openzipkin/zipkin-kafka:2.27.0"));
waitStrategy = Wait.forHealthcheck();
// Kafka broker listener port (19092) needs to be exposed for test cases to access it.
addFixedExposedPort(KAFKA_PORT, KAFKA_PORT, InternetProtocol.TCP);
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<properties>
<main.basedir>${project.basedir}/..</main.basedir>
<!-- use the same value in ../pom.xml -->
<zipkin.version>2.26.0</zipkin.version>
<zipkin.version>2.27.0</zipkin.version>
</properties>

<url>https://github.com/openzipkin/zipkin-reporter-java</url>
Expand Down
7 changes: 3 additions & 4 deletions brave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<module.name>zipkin2.reporter.brave</module.name>

<main.basedir>${project.basedir}/..</main.basedir>

<!-- The brave jar needs to be Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -75,7 +72,9 @@
<id>release</id>
<properties>
<!-- The brave jar needs to be Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -129,7 +129,7 @@ enum Consumer implements TagConsumer<Span.Builder>, AnnotationConsumer<Span.Buil
* Zipkin kind values.
*/
static Map<Kind, Span.Kind> generateKindMap() {
Map<Kind, Span.Kind> result = new LinkedHashMap<>();
Map<Kind, Span.Kind> result = new LinkedHashMap<Kind, Span.Kind>();
// Note: Both Brave and Zipkin treat null kind as a local/in-process span
for (Kind kind : Kind.values()) {
try {
Expand Down
7 changes: 3 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<module.name>zipkin2.reporter</module.name>

<main.basedir>${project.basedir}/..</main.basedir>

<!-- The core jar needs to be Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand All @@ -49,7 +46,9 @@
<id>release</id>
<properties>
<!-- The core jar needs to be Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
17 changes: 10 additions & 7 deletions core/src/main/java/zipkin2/reporter/AsyncReporter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -202,7 +202,7 @@ public <S> AsyncReporter<S> build(BytesEncoder<S> encoder) {
"Encoder doesn't match Sender: %s %s", encoder.encoding(), sender.encoding()));
}

return new BoundedAsyncReporter<>(this, encoder);
return new BoundedAsyncReporter<S>(this, encoder);
}
}

Expand All @@ -222,7 +222,7 @@ static final class BoundedAsyncReporter<S> extends AsyncReporter<S> {
private boolean shouldWarnException = true;

BoundedAsyncReporter(Builder builder, BytesEncoder<S> encoder) {
this.pending = new ByteBoundedQueue<>(builder.queuedMaxSpans, builder.queuedMaxBytes);
this.pending = new ByteBoundedQueue<S>(builder.queuedMaxSpans, builder.queuedMaxBytes);
this.sender = builder.sender;
this.messageMaxBytes = builder.messageMaxBytes;
this.messageTimeoutNanos = builder.messageTimeoutNanos;
Expand All @@ -239,7 +239,7 @@ static final class BoundedAsyncReporter<S> extends AsyncReporter<S> {
void startFlusherThread() {
BufferNextMessage<S> consumer =
BufferNextMessage.create(encoder.encoding(), messageMaxBytes, messageTimeoutNanos);
Thread flushThread = threadFactory.newThread(new Flusher<>(this, consumer));
Thread flushThread = threadFactory.newThread(new Flusher<S>(this, consumer));
flushThread.setName("AsyncReporter{" + sender + "}");
flushThread.setDaemon(true);
flushThread.start();
Expand All @@ -263,7 +263,7 @@ void startFlusherThread() {

@Override public final void flush() {
if (closed.get()) throw new ClosedSenderException();
flush(BufferNextMessage.create(encoder.encoding(), messageMaxBytes, 0));
flush(BufferNextMessage.<S>create(encoder.encoding(), messageMaxBytes, 0));
}

void flush(BufferNextMessage<S> bundler) {
Expand All @@ -282,7 +282,7 @@ void flush(BufferNextMessage<S> bundler) {
metrics.incrementMessageBytes(bundler.sizeInBytes());

// Create the next message. Since we are outside the lock shared with writers, we can encode
ArrayList<byte[]> nextMessage = new ArrayList<>(bundler.count());
final ArrayList<byte[]> nextMessage = new ArrayList<byte[]>(bundler.count());
bundler.drain(new SpanWithSizeConsumer<S>() {
@Override public boolean offer(S next, int nextSizeInBytes) {
nextMessage.add(encoder.encode(next)); // speculatively add to the pending message
Expand Down Expand Up @@ -377,7 +377,10 @@ static final class Flusher<S> implements Runnable {
while (!result.closed.get()) {
result.flush(consumer);
}
} catch (RuntimeException | Error e) {
} catch (RuntimeException e) {
logger.log(Level.WARNING, "Unexpected error flushing spans", e);
throw e;
} catch (Error e) {
logger.log(Level.WARNING, "Unexpected error flushing spans", e);
throw e;
} finally {
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/java/zipkin2/reporter/BufferNextMessage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand All @@ -19,23 +19,22 @@

/** Use of this type happens off the application's main thread. This type is not thread-safe */
abstract class BufferNextMessage<S> implements SpanWithSizeConsumer<S> {

static <S> BufferNextMessage<S> create(Encoding encoding, int maxBytes, long timeoutNanos) {
switch (encoding) {
case JSON:
return new BufferNextJsonMessage<>(maxBytes, timeoutNanos);
return new BufferNextJsonMessage<S>(maxBytes, timeoutNanos);
case THRIFT:
return new BufferNextThriftMessage<>(maxBytes, timeoutNanos);
return new BufferNextThriftMessage<S>(maxBytes, timeoutNanos);
case PROTO3:
return new BufferNextProto3Message<>(maxBytes, timeoutNanos);
return new BufferNextProto3Message<S>(maxBytes, timeoutNanos);
}
throw new UnsupportedOperationException("encoding: " + encoding);
}

final int maxBytes;
final long timeoutNanos;
final ArrayList<S> spans = new ArrayList<>();
final ArrayList<Integer> sizes = new ArrayList<>();
final ArrayList<S> spans = new ArrayList<S>();
final ArrayList<Integer> sizes = new ArrayList<Integer>();

long deadlineNanoTime;
int messageSizeInBytes;
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/zipkin2/reporter/InMemoryReporterMetrics.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -30,9 +30,9 @@ enum MetricKey {
}

private final ConcurrentHashMap<MetricKey, AtomicLong> metrics =
new ConcurrentHashMap<>();
new ConcurrentHashMap<MetricKey, AtomicLong>();
private final ConcurrentHashMap<Class<? extends Throwable>, AtomicLong> messagesDropped =
new ConcurrentHashMap<>();
new ConcurrentHashMap<Class<? extends Throwable>, AtomicLong>();

@Override public void incrementMessages() {
increment(MetricKey.messages, 1);
Expand All @@ -47,7 +47,8 @@ public long messages() {
}

public Map<Class<? extends Throwable>, Long> messagesDroppedByCause() {
Map<Class<? extends Throwable>, Long> result = new LinkedHashMap<>(messagesDropped.size());
Map<Class<? extends Throwable>, Long> result =
new LinkedHashMap<Class<? extends Throwable>, Long>(messagesDropped.size());
for (Map.Entry<Class<? extends Throwable>, AtomicLong> kv : messagesDropped.entrySet()) {
result.put(kv.getKey(), kv.getValue().longValue());
}
Expand Down Expand Up @@ -130,7 +131,7 @@ static <K> void increment(ConcurrentHashMap<K, AtomicLong> metrics, K key, int q
AtomicLong metric = metrics.get(key);
if (metric == null) {
metric = metrics.putIfAbsent(key, new AtomicLong(quantity));
if (metric == null) return; // won race creating the entry
if (metric == null) return; // won race creating the entry
}

while (true) {
Expand Down
Loading

0 comments on commit f195606

Please sign in to comment.