Skip to content

Commit 9cfa52d

Browse files
committed
Improving defaults
1 parent 7e59de9 commit 9cfa52d

23 files changed

+792
-523
lines changed

.github/workflows/build-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
1818
steps:
1919
- name: Setup JDK
20-
uses: actions/setup-java@v4
20+
uses: actions/setup-java@v5
2121
with:
2222
java-version: '21'
2323
distribution: 'temurin'

.github/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
1919
steps:
2020
- name: Setup JDK
21-
uses: actions/setup-java@v4
21+
uses: actions/setup-java@v5
2222
with:
2323
java-version: '21'
2424
distribution: 'temurin'

build.gradle

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ def jarVersion = "3.0.2"
1515
group = 'io.nats'
1616

1717
def isRelease = System.getenv("BUILD_EVENT") == "release"
18+
def tc = System.getenv("TARGET_COMPATIBILITY");
19+
def targetCompat = tc == "21" ? JavaVersion.VERSION_21 : (tc == "17" ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8)
20+
def jarEnd = tc == "21" ? "-jdk21" : (tc == "17" ? "-jdk17" : "")
21+
def jarAndArtifactName = "jnats-server-runner" + jarEnd
1822

19-
// version is the variable the build actually uses.
20-
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT"
23+
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the build actually uses.
24+
25+
System.out.println("Java: " + System.getProperty("java.version"))
26+
System.out.println("Target Compatibility: " + targetCompat)
27+
System.out.println(group + ":" + jarAndArtifactName + ":" + version)
2128

2229
java {
2330
sourceCompatibility = JavaVersion.VERSION_1_8
24-
targetCompatibility = JavaVersion.VERSION_1_8
31+
targetCompatibility = targetCompat
2532
}
2633

2734
repositories {
@@ -31,6 +38,8 @@ repositories {
3138
}
3239

3340
dependencies {
41+
implementation 'org.jspecify:jspecify:1.0.0'
42+
3443
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'
3544
testImplementation 'nl.jqno.equalsverifier:equalsverifier:4.2.1'
3645

@@ -46,7 +55,8 @@ jar {
4655
bnd("Bundle-Name": "io.nats.jnats.server.runner",
4756
"Bundle-Vendor": "nats.io",
4857
"Bundle-Description": "NATS.IO Java Server Runner",
49-
"Bundle-DocURL": "https://github.com/nats-io/java-nats-server-runner"
58+
"Bundle-DocURL": "https://github.com/nats-io/java-nats-server-runner",
59+
"Target-Compatibility": "Java " + targetCompat
5060
)
5161
}
5262
}
@@ -67,6 +77,7 @@ test {
6777
}
6878

6979
javadoc {
80+
failOnError = false
7081
options.overview = 'src/main/javadoc/overview.html' // relative to source root
7182
source = sourceSets.main.allJava
7283
title = "NATS.IO Java Server Runner"
@@ -116,11 +127,11 @@ publishing {
116127
artifact sourcesJar
117128
artifact javadocJar
118129
pom {
119-
name = "jnats-server-runner"
130+
name = jarAndArtifactName
120131
packaging = "jar"
121132
groupId = group
122-
artifactId = "jnats-server-runner"
123-
description = "Java NATS.io server runner."
133+
artifactId = jarAndArtifactName
134+
description = "Java NATS.io Server Runner"
124135
url = 'https://github.com/nats-io/java-nats-server-runner'
125136
licenses {
126137
license {

src/main/java/io/nats/ClusterInsert.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,38 @@
1313

1414
package io.nats;
1515

16+
import org.jspecify.annotations.NonNull;
17+
import org.jspecify.annotations.Nullable;
18+
19+
/**
20+
* Object that represents the lines needed to add to the conf for a custer instance
21+
*/
1622
public class ClusterInsert {
23+
/**
24+
* The node
25+
*/
1726
public final ClusterNode node;
27+
28+
/**
29+
* The actual inserts
30+
*/
1831
public final String[] configInserts;
1932

20-
public ClusterInsert(ClusterNode node, String[] configInserts) {
33+
/**
34+
* Construct a ClusterInsert
35+
* @param node the node
36+
* @param configInserts the inserts
37+
*/
38+
public ClusterInsert(@NonNull ClusterNode node, String @Nullable [] configInserts) {
2139
this.node = node;
2240
this.configInserts = configInserts == null || configInserts.length == 0 ? null : configInserts;
2341
}
2442

2543
@Override
2644
public String toString() {
45+
if (configInserts == null) {
46+
return node.toString();
47+
}
2748
StringBuilder sb = new StringBuilder();
2849
for (String s : configInserts) {
2950
sb.append(s).append("\r\n");

src/main/java/io/nats/ClusterNode.java

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,59 @@
1313

1414
package io.nats;
1515

16+
import org.jspecify.annotations.NullMarked;
17+
import org.jspecify.annotations.NullUnmarked;
18+
import org.jspecify.annotations.Nullable;
19+
1620
import java.nio.file.Path;
1721

22+
/**
23+
* An object representing a single server node
24+
*/
25+
@NullMarked
1826
public class ClusterNode {
27+
/** The name of the cluster */
1928
public final String clusterName;
29+
/** The name of the server */
2030
public final String serverName;
31+
/** The port */
2132
public final int port;
33+
/** The listen port */
2234
public final int listen;
23-
public final String host;
24-
public final Integer monitor;
25-
public final Path jsStoreDir;
26-
35+
/** The host */
36+
@Nullable public final String host;
37+
/** The monitor port, may be null */
38+
@Nullable public final Integer monitor;
39+
/** A custom path to use as the JetStream storage directory */
40+
@Nullable public final Path jsStoreDir;
41+
42+
/**
43+
* Construct a ClusterNode
44+
* @param clusterName the cluster name
45+
* @param serverName the server name
46+
* @param port the port
47+
* @param listen the listen port
48+
*/
2749
public ClusterNode(String clusterName, String serverName, int port, int listen) {
2850
this(clusterName, serverName, null, port, listen, null, null);
2951
}
3052

31-
public ClusterNode(String clusterName, String serverName, int port, int listen, Integer monitor) {
53+
/**
54+
* Construct a ClusterNode
55+
* @param clusterName the cluster name
56+
* @param serverName the server name
57+
* @param port the port
58+
* @param listen the listen port
59+
*/
60+
public ClusterNode(String clusterName, String serverName, int port, int listen, @Nullable Integer monitor) {
3261
this(clusterName, serverName, null, port, listen, monitor, null);
3362
}
3463

35-
public ClusterNode(String clusterName, String serverName, int port, int listen, Path jsStoreDir) {
64+
public ClusterNode(String clusterName, String serverName, int port, int listen, @Nullable Path jsStoreDir) {
3665
this(clusterName, serverName, null, port, listen, null, jsStoreDir);
3766
}
3867

39-
public ClusterNode(String clusterName, String serverName, String host, int port, int listen, Integer monitor, Path jsStoreDir) {
68+
public ClusterNode(String clusterName, String serverName, @Nullable String host, int port, int listen, @Nullable Integer monitor, @Nullable Path jsStoreDir) {
4069
this.clusterName = clusterName;
4170
this.serverName = serverName;
4271
this.host = host;
@@ -46,15 +75,29 @@ public ClusterNode(String clusterName, String serverName, String host, int port,
4675
this.jsStoreDir = jsStoreDir;
4776
}
4877

78+
@Override
79+
public String toString() {
80+
return "ClusterNode{" +
81+
"clusterName='" + clusterName + '\'' +
82+
", serverName='" + serverName + '\'' +
83+
", port=" + port +
84+
", listen=" + listen +
85+
", host='" + host + '\'' +
86+
", monitor=" + monitor +
87+
", jsStoreDir=" + jsStoreDir +
88+
'}';
89+
}
90+
4991
public static Builder builder() {
5092
return new Builder();
5193
}
5294

95+
@NullUnmarked
5396
public static class Builder {
5497
private String clusterName;
5598
private String serverName;
56-
private int port;
57-
private int listen;
99+
private int port = -1;
100+
private int listen = -1;
58101
private String host;
59102
private Integer monitor;
60103
private Path jsStoreDir;

0 commit comments

Comments
 (0)