Skip to content

Commit 23821e3

Browse files
committed
Apply OpenRewrite Java17 migration
1 parent a198728 commit 23821e3

5 files changed

Lines changed: 18 additions & 15 deletions

File tree

ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void start(Stage stage) {
6868
scene = new Scene(root, WIDTH, HEIGHT);
6969

7070
stage.setScene(scene);
71-
stage.setTitle(String.format("FAF ICE adapter - Debugger - Build: %s", IceAdapter.VERSION));
71+
stage.setTitle("FAF ICE adapter - Debugger - Build: %s".formatted(IceAdapter.VERSION));
7272
// stage.setOnCloseRequest(Event::consume);
7373
// stage.show();
7474

@@ -98,11 +98,11 @@ public void startupComplete() {
9898
public void initStaticVariables() {
9999

100100
runOnUIThread(() -> {
101-
controller.versionLabel.setText(String.format("Version: %s", IceAdapter.VERSION));
102-
controller.userLabel.setText(String.format("User: %s(%d)", IceAdapter.login, IceAdapter.id));
103-
controller.rpcPortLabel.setText(String.format("RPC_PORT: %d", IceAdapter.RPC_PORT));
104-
controller.gpgnetPortLabel.setText(String.format("GPGNET_PORT: %d", IceAdapter.GPGNET_PORT));
105-
controller.lobbyPortLabel.setText(String.format("LOBBY_PORT: %d", IceAdapter.LOBBY_PORT));
101+
controller.versionLabel.setText("Version: %s".formatted(IceAdapter.VERSION));
102+
controller.userLabel.setText("User: %s(%d)".formatted(IceAdapter.login, IceAdapter.id));
103+
controller.rpcPortLabel.setText("RPC_PORT: %d".formatted(IceAdapter.RPC_PORT));
104+
controller.gpgnetPortLabel.setText("GPGNET_PORT: %d".formatted(IceAdapter.GPGNET_PORT));
105+
controller.lobbyPortLabel.setText("LOBBY_PORT: %d".formatted(IceAdapter.LOBBY_PORT));
106106
});
107107
}
108108

@@ -127,7 +127,7 @@ public void rpcStarted(CompletableFuture<JJsonPeer> peerFuture) {
127127
});
128128
peerFuture.thenAccept(peer -> runOnUIThread(() -> {
129129
controller.rpcClientStatus.setText(
130-
String.format("RPCClient: %s", peer.getSocket().getInetAddress()));
130+
"RPCClient: %s".formatted(peer.getSocket().getInetAddress()));
131131
}));
132132
}
133133

@@ -142,7 +142,7 @@ public void gpgnetStarted() {
142142
public void gpgnetConnectedDisconnected() {
143143
runOnUIThread(() -> {
144144
controller.gpgnetServerStatus.setText(
145-
String.format("GPGNetClient: %s", GPGNetServer.isConnected() ? "connected" : "-"));
145+
"GPGNetClient: %s".formatted(GPGNetServer.isConnected() ? "connected" : "-"));
146146
gameStateChanged();
147147
});
148148
}

ice-adapter/src/main/java/com/faforever/iceadapter/debug/TextAreaLogAppender.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ private void appendText(String text) {
6464

6565
public void setTextArea(Object textArea) {
6666
if (!textArea.getClass().getCanonicalName().equals("javafx.scene.control.TextArea")) {
67-
throw new RuntimeException(String.format(
68-
"Object is of class %s, expected javafx.scene.control.TextArea",
69-
textArea.getClass().getCanonicalName()));
67+
throw new RuntimeException("Object is of class %s, expected javafx.scene.control.TextArea"
68+
.formatted(textArea.getClass().getCanonicalName()));
7069
}
7170
this.textArea = textArea;
7271
try {

ice-adapter/src/main/java/com/faforever/iceadapter/ice/Peer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ public void close() {
131131
* @return %username%(%id%)
132132
*/
133133
public String getPeerIdentifier() {
134-
return String.format("%s(%d)", this.remoteLogin, this.remoteId);
134+
return "%s(%d)".formatted(this.remoteLogin, this.remoteId);
135135
}
136136
}

ice-adapter/src/main/java/com/faforever/iceadapter/ice/PeerIceModule.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.CancellationException;
1616
import java.util.concurrent.CompletableFuture;
1717
import java.util.concurrent.CompletionException;
18+
import java.util.concurrent.ThreadLocalRandom;
1819
import java.util.concurrent.atomic.AtomicInteger;
1920
import java.util.stream.Collectors;
2021
import lombok.Getter;
@@ -121,7 +122,10 @@ a, new LongTermCredential(iceServer.getTurnUsername(), iceServer.getTurnCredenti
121122
CompletableFuture<Void> gatheringFuture = CompletableFuture.runAsync(() -> {
122123
try {
123124
component = agent.createComponent(
124-
mediaStream, MINIMUM_PORT + (int) (Math.random() * 999.0), MINIMUM_PORT, MINIMUM_PORT + 1000);
125+
mediaStream,
126+
MINIMUM_PORT + (int) (ThreadLocalRandom.current().nextDouble() * 999.0),
127+
MINIMUM_PORT,
128+
MINIMUM_PORT + 1000);
125129
} catch (IOException e) {
126130
throw new RuntimeException(e);
127131
}
@@ -513,6 +517,6 @@ public int getConnectivityAttempsInThePast(final long millis) {
513517
}
514518

515519
public String getLogPrefix() {
516-
return String.format("ICE %s: ", peer.getPeerIdentifier());
520+
return "ICE %s: ".formatted(peer.getPeerIdentifier());
517521
}
518522
}

ice-adapter/src/test/java/IceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void main(String args[]) throws IOException {
4343
System.out.printf("Username: %s\n", username);
4444

4545
int timestamp = (int) (System.currentTimeMillis() / 1000) + 3600 * 24;
46-
String tokenName = String.format("%s:%s", timestamp, username);
46+
String tokenName = "%s:%s".formatted(timestamp, username);
4747
byte[] secret = null;
4848
try {
4949
Mac mac = Mac.getInstance("HmacSHA1");

0 commit comments

Comments
 (0)