Skip to content

Commit

Permalink
Raises floor JRE version from 11 to 17 except core (#3763)
Browse files Browse the repository at this point in the history
This raises the floor JRE version of libraries except core from 11 to
17. The only reason we had 17 in the past was due to Spark limitations
that affected zipkin-dependencies. After this, folks can also consider
getting rid of AutoValue for the record type (sadly no OpenRewrite for
that ;).

This change was manual except the parts about string formatting,
exception coercing and multi-line literals. Those parts were done with
OpenRewrite via below (reverting changes to core):

```bash
$ mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava17
```

The other non-manual step was about JOOQ, which was copy/pasting
commands from the README, which worked without any issue.

---------

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Apr 16, 2024
1 parent 846ad9a commit b44940d
Show file tree
Hide file tree
Showing 46 changed files with 467 additions and 137 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ does not use this library. So, [brave](https://github.com/openzipkin/brave) stil
## Storage Component
Zipkin includes a [StorageComponent](zipkin/src/main/java/zipkin2/storage/StorageComponent.java), used to store and query spans and
dependency links. This is used by the server and those making collectors, or span reporters.
For this reason, storage components have minimal dependencies, though require Java 11+.
For this reason, storage components have minimal dependencies, though require Java 17+.

Ex.
```java
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>benchmarks</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions docker/test-images/zipkin-eureka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<description>Netflix Eureka test binary</description>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<!-- Get rid of transitive CVE warnings, except commons-jxpath which is abandoned -->
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand All @@ -30,12 +30,12 @@
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- With two exceptions, main code is Java 11
* zipkin core Jar is Java 1.8
* zipkin-server is 17, as that's the floor of Spring Boot 3. -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<!-- Except for zipkin core Jar (Java 1.8), everything is 17, as that's
the minimum of Spring Boot 3, required for recent JOOQ and works with
zipkin-dependencies (Spark 3.4+). -->
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.testSource>17</maven.compiler.testSource>
<maven.compiler.testTarget>17</maven.compiler.testTarget>
<maven.compiler.testRelease>17</maven.compiler.testRelease>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Modules here implement popular transport options available by default in
the [server build](../zipkin-server).

Please note all modules here require JRE 11+
Please note all modules here require JRE 17+

These libraries are also usable outside the server, for example in
custom collectors or storage pipelines. While compatibility guarantees
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-collector-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-collector-activemq</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public Builder concurrency(int concurrency) {

static RuntimeException uncheckedException(String prefix, JMSException e) {
Exception cause = e.getLinkedException();
if (cause instanceof IOException) {
return new UncheckedIOException(prefix + message(cause), (IOException) cause);
if (cause instanceof IOException exception) {
return new UncheckedIOException(prefix + message(cause), exception);
}
return new RuntimeException(prefix + message(e), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ void registerInNewSession(ActiveMQConnection connection, String queue) throws JM
metrics.incrementMessages();
byte[] serialized; // TODO: consider how to reuse buffers here
try {
if (message instanceof BytesMessage) {
BytesMessage bytesMessage = (BytesMessage) message;
if (message instanceof BytesMessage bytesMessage) {
serialized = new byte[(int) bytesMessage.getBodyLength()];
bytesMessage.readBytes(serialized);
} else if (message instanceof TextMessage) {
String text = ((TextMessage) message).getText();
} else if (message instanceof TextMessage textMessage) {
String text = textMessage.getText();
serialized = text.getBytes(UTF_8);
} else {
metrics.incrementMessagesDropped();
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-collector-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-collector</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import zipkin2.codec.SpanBytesDecoder;
import zipkin2.storage.StorageComponent;

import static java.lang.String.format;
import static zipkin2.Call.propagateIfFatal;

/**
Expand Down Expand Up @@ -265,7 +264,7 @@ void handleError(Throwable e, Supplier<String> defaultLogMessage, Callback<Void>
logger.debug(error, e);
} else { // otherwise, beautify the message
String message =
format("%s due to %s(%s)", defaultLogMessage.get(), e.getClass().getSimpleName(), error);
"%s due to %s(%s)".formatted(defaultLogMessage.get(), e.getClass().getSimpleName(), error);
logger.debug(message, e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-collector-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-collector-kafka</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<groupId>io.zipkin.zipkin2</groupId>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/rabbitmq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-collector-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-collector-rabbitmq</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-collector/scribe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-collector-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-collector-scribe</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Log(List<LogEntry> messages, AsyncMethodCallback<ResultCode> resultH
}

@Override public void onError(Throwable t) {
Exception error = t instanceof Exception ? (Exception) t : new RuntimeException(t);
Exception error = t instanceof Exception e ? e : new RuntimeException(t);
resultHandler.onError(error);
}
// Collectors may not be asynchronous so switch to blocking executor here.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zipkin-junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<groupId>io.zipkin.zipkin2</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ZipkinExtension() {

/** Use this to connect. The zipkin v1 interface will be under "/api/v1" */
public String httpUrl() {
return String.format("http://%s:%s", server.getHostName(), server.getPort());
return "http://%s:%s".formatted(server.getHostName(), server.getPort());
}

/** Use this to see how many requests you've sent to any zipkin http endpoint. */
Expand Down
2 changes: 1 addition & 1 deletion zipkin-lens/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-lens</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions zipkin-server/RATIONALE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ such as our ability to change spring boot or armeria whenever we want.
## Java 17

As Zipkin Server is a Spring Boot 3 application, it requires minimum JRE 17 to
run. The collector and storage modules it uses remain at Java 11 bytecode until
the zipkin-dependencies job can run on JRE 17, or its tests no longer share
storage classes.
run. Its collector and storage modules are also used by zipkin-dependencies
which as of version 3.2 can operate on JRE 17 (due to Spark 3.4+).

## Modules

Expand Down
2 changes: 1 addition & 1 deletion zipkin-server/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# zipkin-server
Zipkin Server is a Java 11+ service, packaged as an executable jar.
Zipkin Server is a Java 17+ service, packaged as an executable jar.

Span storage and collectors are [configurable](#configuration). By default, storage is in-memory,
the HTTP collector (POST /api/v2/spans endpoint) is enabled, and the server listens on port 9411.
Expand Down
2 changes: 1 addition & 1 deletion zipkin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-storage/cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-storage-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-storage-cassandra</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static Metadata validate(CassandraStorage cassandra, CqlSession session) {
}

static void logAndThrow(String messageFormat, Object... args) {
String message = String.format(messageFormat, args);
String message = messageFormat.formatted(args);
// Ensure we can look at logs to see the problem. Otherwise, it may only
// be visible in API error responses, such as /health or /api/v2/traces.
LOG.error(message);
Expand Down Expand Up @@ -124,8 +124,8 @@ static KeyspaceMetadata ensureKeyspaceMetadata(CqlSession session, String keyspa
KeyspaceMetadata keyspaceMetadata = session.getMetadata().getKeyspace(keyspace).orElse(null);
if (keyspaceMetadata == null) {
throw new IllegalStateException(
String.format(
"Cannot read keyspace metadata for keyspace: %s and cluster: %s",

"Cannot read keyspace metadata for keyspace: %s and cluster: %s".formatted(
keyspace, session.getMetadata().getClusterName()));
}
return keyspaceMetadata;
Expand All @@ -137,8 +137,8 @@ static Version ensureVersion(com.datastax.oss.driver.api.core.metadata.Metadata
version = entry.getValue().getCassandraVersion();
if (version == null) throw new RuntimeException("node had no version: " + entry.getValue());
if (Version.parse("3.11.3").compareTo(version) > 0) {
throw new RuntimeException(String.format(
"Node %s is running Cassandra %s, but minimum version is 3.11.3",
throw new RuntimeException(
"Node %s is running Cassandra %s, but minimum version is 3.11.3".formatted(
entry.getKey(), entry.getValue().getCassandraVersion()));
}
}
Expand Down Expand Up @@ -194,7 +194,7 @@ static void applyCqlFile(Version version, String keyspace, CqlSession session, S
session.execute(cmd);
} catch (InvalidQueryException e) {
// Add context so it is obvious which line was wrong
String message = String.format("Failed to execute [%s]: %s", cmd, e.getMessage());
String message = "Failed to execute [%s]: %s".formatted(cmd, e.getMessage());
// Ensure we can look at logs to see the problem. Otherwise, it may only
// be visible in API error responses, such as /health or /api/v2/traces.
LOG.error(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ static final class Factory {

Factory(CqlSession session) {
this.session = session;
String querySuffix = "annotation_query LIKE ?"
+ " AND ts_uuid>=?"
+ " AND ts_uuid<=?"
+ " LIMIT ?"
+ " ALLOW FILTERING";
String querySuffix = """
annotation_query LIKE ?\
AND ts_uuid>=?\
AND ts_uuid<=?\
LIMIT ?\
ALLOW FILTERING\
""";
this.withAnnotationQuery = session.prepare("SELECT trace_id,ts"
+ " FROM " + TABLE_SPAN
+ " WHERE " + querySuffix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ static <T> T getUninterruptibly(CompletionStage<T> stage) {
interrupted = true;
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof DriverException) {
throw ((DriverException) cause).copy();
if (cause instanceof DriverException exception) {
throw exception.copy();
}
if (cause instanceof RuntimeException) throw (RuntimeException) cause;
if (cause instanceof Error) throw (Error) cause;
if (cause instanceof RuntimeException exception) throw exception;
if (cause instanceof Error error) throw error;
throw new DriverExecutionException(cause);
}
}
Expand Down
2 changes: 1 addition & 1 deletion zipkin-storage/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-storage-parent</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-storage-elasticsearch</artifactId>
Expand Down
Loading

0 comments on commit b44940d

Please sign in to comment.