Skip to content

Commit 03e9218

Browse files
committed
upgrade to java 22
1 parent 465fa49 commit 03e9218

21 files changed

+120
-25
lines changed

.github/workflows/basic-checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Basic checks
33
on: [pull_request]
44

55
env:
6-
JAVA_VERSION: 21
6+
JAVA_VERSION: 22
77

88
jobs:
99
spotless:

.github/workflows/code-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- cron: '0 20 * * 4'
99

1010
env:
11-
JAVA_VERSION: 21
11+
JAVA_VERSION: 22
1212

1313
jobs:
1414
sonar:

.github/workflows/docker-publish.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- 'master'
88

99
env:
10-
JAVA_VERSION: 21
10+
JAVA_VERSION: 22
1111

1212
jobs:
1313
docker:

.github/workflows/docker-verify.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Docker Verify
33
on: [pull_request]
44

55
env:
6-
JAVA_VERSION: 21
6+
JAVA_VERSION: 22
77

88
jobs:
99
docker:

.github/workflows/releases.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defaults:
1010
shell: bash
1111

1212
env:
13-
JAVA_VERSION: 21
13+
JAVA_VERSION: 22
1414

1515
jobs:
1616

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TJ-Bot
22

33
[![codefactor](https://img.shields.io/codefactor/grade/github/together-java/tj-bot)](https://www.codefactor.io/repository/github/together-java/tj-bot)
4-
![Java](https://img.shields.io/badge/Java-21-ff696c)
4+
![Java](https://img.shields.io/badge/Java-22-ff696c)
55
[![license](https://img.shields.io/github/license/Together-Java/TJ-Bot)](https://github.com/Together-Java/TJ-Bot/blob/master/LICENSE)
66
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Together-Java/TJ-Bot?label=release)
77

application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public void onMessageUpdated(MessageUpdateEvent event) {
224224

225225
// Re-apply the current action
226226
return codeReplyMessage.editMessageEmbeds(maybeCodeAction.orElseThrow().apply(code));
227-
}).queue(any -> {
227+
}).queue(_ -> {
228228
}, failure -> logger.warn(
229229
"Attempted to update a code-reply-message ({}), but failed. The original code-message was {}",
230230
codeReplyMessageId, originalMessageId, failure));
@@ -253,7 +253,7 @@ public void onMessageDeleted(MessageDeleteEvent event) {
253253
// Delete the code reply as well
254254
originalMessageToCodeReply.invalidate(originalMessageId);
255255

256-
event.getChannel().deleteMessageById(codeReplyMessageId).queue(any -> {
256+
event.getChannel().deleteMessageById(codeReplyMessageId).queue(_ -> {
257257
}, failure -> logger.warn(
258258
"Attempted to delete a code-reply-message ({}), but failed. The original code-message was {}",
259259
codeReplyMessageId, originalMessageId, failure));

application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
3636
.filter(thread -> thread.getOwnerIdLong() == event.getUser().getIdLong())
3737
.filter(thread -> thread.getParentChannel().getName().matches(helpForumPattern))
3838
.forEach(thread -> thread.sendMessageEmbeds(embed)
39-
.flatMap(any -> thread.getManager().setArchived(true))
39+
.flatMap(_ -> thread.getManager().setArchived(true))
4040
.queue()));
4141
}
4242
}

application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ RestAction<Message> constructChatGptAttempt(ThreadChannel threadChannel,
165165
}
166166

167167
MessageEmbed responseEmbed = generateGptResponseEmbed(answer, selfUser, originalQuestion);
168-
return message.flatMap(any -> threadChannel.sendMessageEmbeds(responseEmbed)
168+
return message.flatMap(_ -> threadChannel.sendMessageEmbeds(responseEmbed)
169169
.addActionRow(
170170
generateDismissButton(componentIdInteractor, idForDismissButton.toString())));
171171
}

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void triggerArchiveFlow(ThreadChannel threadChannel, long authorId,
151151

152152
return sendEmbedWithMention.apply(authorResults.get());
153153
})
154-
.flatMap(any -> threadChannel.getManager().setArchived(true))
154+
.flatMap(_ -> threadChannel.getManager().setArchived(true))
155155
.queue();
156156
}
157157

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) {
102102
.collect(Collectors.toMap(Subcommand::getCommandName, Function.identity()));
103103
subcommandToCooldownCache = new EnumMap<>(streamSubcommands()
104104
.filter(Subcommand::hasCooldown)
105-
.collect(Collectors.toMap(Function.identity(), any -> createCooldownCache.get())));
105+
.collect(Collectors.toMap(Function.identity(), _ -> createCooldownCache.get())));
106106
subcommandToEventHandler = new EnumMap<>(Map.of(Subcommand.CHANGE_CATEGORY,
107107
this::changeCategory, Subcommand.CHANGE_TITLE, this::changeTitle, Subcommand.CLOSE,
108108
this::closeThread, Subcommand.RESET_ACTIVITY, this::resetActivity));
@@ -158,7 +158,7 @@ private void changeCategory(SlashCommandInteractionEvent event, ThreadChannel he
158158
refreshCooldownFor(Subcommand.CHANGE_CATEGORY, helpThread);
159159

160160
helper.changeChannelCategory(helpThread, category)
161-
.flatMap(any -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(),
161+
.flatMap(_ -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(),
162162
helpThread, category))
163163
.queue();
164164
}
@@ -185,7 +185,7 @@ private RestAction<Message> sendCategoryChangedMessage(Guild guild, InteractionH
185185
String headsUpPattern = "%s please have a look, thanks.";
186186
String headsUpWithoutRole = headsUpPattern.formatted("");
187187
String headsUpWithRole = headsUpPattern.formatted(helperRole.orElseThrow().getAsMention());
188-
return action.flatMap(any -> helpThread.sendMessage(headsUpWithoutRole)
188+
return action.flatMap(_ -> helpThread.sendMessage(headsUpWithoutRole)
189189
.flatMap(message -> message.editMessage(headsUpWithRole)));
190190
}
191191

@@ -195,7 +195,7 @@ private void changeTitle(SlashCommandInteractionEvent event, ThreadChannel helpT
195195
refreshCooldownFor(Subcommand.CHANGE_TITLE, helpThread);
196196

197197
helper.renameChannel(helpThread, title)
198-
.flatMap(any -> event.reply("Changed the title to **%s**.".formatted(title)))
198+
.flatMap(_ -> event.reply("Changed the title to **%s**.".formatted(title)))
199199
.queue();
200200
}
201201

@@ -206,7 +206,7 @@ private void closeThread(SlashCommandInteractionEvent event, ThreadChannel helpT
206206
.setColor(HelpSystemHelper.AMBIENT_COLOR)
207207
.build();
208208

209-
event.replyEmbeds(embed).flatMap(any -> helpThread.getManager().setArchived(true)).queue();
209+
event.replyEmbeds(embed).flatMap(_ -> helpThread.getManager().setArchived(true)).queue();
210210
}
211211

212212
private void resetActivity(SlashCommandInteractionEvent event, ThreadChannel helpThread) {

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private boolean wasThreadAlreadyHandled(long threadChannelId) {
7676
// the threads we already handled
7777
Instant now = Instant.now();
7878
// NOTE It is necessary to do the "check if exists, otherwise insert" atomic
79-
Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, any -> now);
79+
Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, _ -> now);
8080
return createdAt != now;
8181
}
8282

application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
4646
}
4747

4848
if (messageHasNoMediaAttached(message)) {
49-
message.delete().flatMap(any -> dmUser(message)).queue(any -> {
49+
message.delete().flatMap(_ -> dmUser(message)).queue(_ -> {
5050
}, failure -> tempNotifyUserInChannel(message));
5151
}
5252
}

application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
150150
// Has been handled if original message was deleted by now.
151151
// Deleted messages cause retrieveMessageById to fail.
152152
Consumer<Message> notHandledAction =
153-
any -> transferFlow(event, channelId, authorId, messageId);
153+
_ -> transferFlow(event, channelId, authorId, messageId);
154154

155155
Consumer<Throwable> handledAction = failure -> {
156156
if (failure instanceof ErrorResponseException errorResponseException

application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
4949
}
5050

5151
private void handleBadMessage(Message message) {
52-
message.delete().flatMap(any -> dmUser(message)).queue(any -> warnMods(message));
52+
message.delete().flatMap(_ -> dmUser(message)).queue(_ -> warnMods(message));
5353
}
5454

5555
private RestAction<Message> dmUser(Message message) {

application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private void dmUser(MessageReceivedEvent event) {
255255
}
256256

257257
private void dmUser(Guild guild, long userId, JDA jda) {
258-
jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(any -> {
258+
jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(_ -> {
259259
}, failure -> logger.debug(
260260
"Unable to send dm message to user {} in guild {} to inform them about a scam message being blocked",
261261
userId, guild.getId(), failure));

application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Failed to send a reminder with (authorID '{}') skipping it. This can be due to a
154154

155155
int failureAttempts = pendingReminder.getFailureAttempts() + 1;
156156
Instant remindAt = Instant.now().plus(1, ChronoUnit.MINUTES);
157-
database.write(any -> {
157+
database.write(_ -> {
158158
pendingReminder.setRemindAt(remindAt);
159159
pendingReminder.setFailureAttempts(failureAttempts);
160160
pendingReminder.insert();

application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static CompletableFuture<List<LinkPreview>> createLinkPreviews(List<Strin
6363
.toList();
6464

6565
var allDoneTask = CompletableFuture.allOf(tasks.toArray(CompletableFuture[]::new));
66-
return allDoneTask.thenApply(any -> extractResults(tasks)).exceptionally(e -> {
66+
return allDoneTask.thenApply(_ -> extractResults(tasks)).exceptionally(e -> {
6767
logger.error("Unknown error during link preview creation", e);
6868
return List.of();
6969
});

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ subprojects {
5555
java {
5656
toolchain {
5757
// Nails the Java-Version of every Subproject
58-
languageVersion = JavaLanguageVersion.of(21)
58+
languageVersion = JavaLanguageVersion.of(22)
5959
}
6060
}
6161

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

+95
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
@rem
23
@rem Copyright 2015 the original author or authors.
34
@rem
@@ -90,3 +91,97 @@ exit /b %EXIT_CODE%
9091
if "%OS%"=="Windows_NT" endlocal
9192

9293
:omega
94+
=======
95+
@rem
96+
@rem Copyright 2015 the original author or authors.
97+
@rem
98+
@rem Licensed under the Apache License, Version 2.0 (the "License");
99+
@rem you may not use this file except in compliance with the License.
100+
@rem You may obtain a copy of the License at
101+
@rem
102+
@rem https://www.apache.org/licenses/LICENSE-2.0
103+
@rem
104+
@rem Unless required by applicable law or agreed to in writing, software
105+
@rem distributed under the License is distributed on an "AS IS" BASIS,
106+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
107+
@rem See the License for the specific language governing permissions and
108+
@rem limitations under the License.
109+
@rem
110+
111+
@if "%DEBUG%"=="" @echo off
112+
@rem ##########################################################################
113+
@rem
114+
@rem Gradle startup script for Windows
115+
@rem
116+
@rem ##########################################################################
117+
118+
@rem Set local scope for the variables with windows NT shell
119+
if "%OS%"=="Windows_NT" setlocal
120+
121+
set DIRNAME=%~dp0
122+
if "%DIRNAME%"=="" set DIRNAME=.
123+
@rem This is normally unused
124+
set APP_BASE_NAME=%~n0
125+
set APP_HOME=%DIRNAME%
126+
127+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
128+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
129+
130+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
131+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
132+
133+
@rem Find java.exe
134+
if defined JAVA_HOME goto findJavaFromJavaHome
135+
136+
set JAVA_EXE=java.exe
137+
%JAVA_EXE% -version >NUL 2>&1
138+
if %ERRORLEVEL% equ 0 goto execute
139+
140+
echo. 1>&2
141+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
142+
echo. 1>&2
143+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
144+
echo location of your Java installation. 1>&2
145+
146+
goto fail
147+
148+
:findJavaFromJavaHome
149+
set JAVA_HOME=%JAVA_HOME:"=%
150+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
151+
152+
if exist "%JAVA_EXE%" goto execute
153+
154+
echo. 1>&2
155+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
156+
echo. 1>&2
157+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
158+
echo location of your Java installation. 1>&2
159+
160+
goto fail
161+
162+
:execute
163+
@rem Setup the command line
164+
165+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
166+
167+
168+
@rem Execute Gradle
169+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
170+
171+
:end
172+
@rem End local scope for the variables with windows NT shell
173+
if %ERRORLEVEL% equ 0 goto mainEnd
174+
175+
:fail
176+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
177+
rem the _cmd.exe /c_ return code!
178+
set EXIT_CODE=%ERRORLEVEL%
179+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
180+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
181+
exit /b %EXIT_CODE%
182+
183+
:mainEnd
184+
if "%OS%"=="Windows_NT" endlocal
185+
186+
:omega
187+
>>>>>>> 78d0197 (upgrade to java 22)

0 commit comments

Comments
 (0)