Skip to content

Bump Java Version to 24 #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/basic-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Basic checks
on: [pull_request]

env:
JAVA_VERSION: 21
JAVA_VERSION: 24

jobs:
spotless:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- cron: '0 20 * * 4'

env:
JAVA_VERSION: 21
JAVA_VERSION: 24

jobs:
sonar:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'master'

env:
JAVA_VERSION: 21
JAVA_VERSION: 24

jobs:
docker:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Docker Verify
on: [pull_request]

env:
JAVA_VERSION: 21
JAVA_VERSION: 24

jobs:
docker:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defaults:
shell: bash

env:
JAVA_VERSION: 21
JAVA_VERSION: 24

jobs:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TJ-Bot

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

Expand Down
4 changes: 2 additions & 2 deletions application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

plugins {
id 'application'
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.5'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'database-settings'
}
Expand All @@ -18,7 +18,7 @@ repositories {
var outputImage = 'togetherjava.org:5001/togetherjava/tjbot:' + System.getenv('BRANCH_NAME') ?: 'latest'

jib {
from.image = 'eclipse-temurin:21'
from.image = 'eclipse-temurin:24'
to {
image = outputImage
auth {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void onMessageUpdated(MessageUpdateEvent event) {

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

event.getChannel().deleteMessageById(codeReplyMessageId).queue(any -> {
event.getChannel().deleteMessageById(codeReplyMessageId).queue(_ -> {
}, failure -> logger.warn(
"Attempted to delete a code-reply-message ({}), but failed. The original code-message was {}",
codeReplyMessageId, originalMessageId, failure));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void addComponentIdRemovedListener(Consumer<ComponentId> listener) {
* @throws InvalidComponentIdFormatException if the given component ID was in an unexpected
* format and could not be serialized
*/
@SuppressWarnings("WeakerAccess")
@SuppressWarnings({"WeakerAccess", "squid:S2259"})
public Optional<ComponentId> get(UUID uuid) {
synchronized (storeLock) {
// Get it from the cache or, if not found, the database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Optional<GHIssue> findIssue(int id, String targetIssueTitle) {
if (issue.getTitle().equals(targetIssueTitle)) {
return Optional.of(issue);
}
} catch (FileNotFoundException ignored) {
} catch (FileNotFoundException _) {
return Optional.<GHIssue>empty();
} catch (IOException ex) {
throw new UncheckedIOException(ex);
Expand All @@ -255,7 +255,7 @@ Optional<GHIssue> findIssue(int id, long defaultRepoId) {
issue = repository.getPullRequest(id);
}
return Optional.of(issue);
} catch (FileNotFoundException ignored) {
} catch (FileNotFoundException _) {
return Optional.<GHIssue>empty();
} catch (IOException ex) {
throw new UncheckedIOException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
.filter(thread -> thread.getOwnerIdLong() == event.getUser().getIdLong())
.filter(thread -> thread.getParentChannel().getName().matches(helpForumPattern))
.forEach(thread -> thread.sendMessageEmbeds(embed)
.flatMap(any -> thread.getManager().setArchived(true))
.flatMap(_ -> thread.getManager().setArchived(true))
.queue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ RestAction<Message> constructChatGptAttempt(ThreadChannel threadChannel,
}

MessageEmbed responseEmbed = generateGptResponseEmbed(answer, selfUser, originalQuestion);
return post.flatMap(any -> threadChannel.sendMessageEmbeds(responseEmbed)
return post.flatMap(_ -> threadChannel.sendMessageEmbeds(responseEmbed)
.addActionRow(generateDismissButton(componentIdInteractor, messageId.get())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void triggerArchiveFlow(ThreadChannel threadChannel, long authorId,

return sendEmbedWithMention.apply(authorResults.get());
})
.flatMap(any -> threadChannel.getManager().setArchived(true))
.flatMap(_ -> threadChannel.getManager().setArchived(true))
.queue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) {
.collect(Collectors.toMap(Subcommand::getCommandName, Function.identity()));
subcommandToCooldownCache = new EnumMap<>(streamSubcommands()
.filter(Subcommand::hasCooldown)
.collect(Collectors.toMap(Function.identity(), any -> createCooldownCache.get())));
.collect(Collectors.toMap(Function.identity(), _ -> createCooldownCache.get())));
subcommandToEventHandler = new EnumMap<>(Map.of(Subcommand.CHANGE_CATEGORY,
this::changeCategory, Subcommand.CHANGE_TITLE, this::changeTitle, Subcommand.CLOSE,
this::closeThread, Subcommand.RESET_ACTIVITY, this::resetActivity));
Expand All @@ -124,6 +124,7 @@ && isHelpThreadOnCooldown(invokedSubcommand, helpThread)) {
subcommandToEventHandler.get(invokedSubcommand).accept(event, helpThread);
}

@SuppressWarnings("squid:S2259")
private boolean isHelpThreadOnCooldown(Subcommand subcommand, ThreadChannel helpThread) {
Cache<? super Long, Instant> helpThreadIdToLastAction = requireCooldownCache(subcommand);
return Optional.ofNullable(helpThreadIdToLastAction.getIfPresent(helpThread.getIdLong()))
Expand Down Expand Up @@ -158,7 +159,7 @@ private void changeCategory(SlashCommandInteractionEvent event, ThreadChannel he
refreshCooldownFor(Subcommand.CHANGE_CATEGORY, helpThread);

helper.changeChannelCategory(helpThread, category)
.flatMap(any -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(),
.flatMap(_ -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(),
helpThread, category))
.queue();
}
Expand All @@ -185,7 +186,7 @@ private RestAction<Message> sendCategoryChangedMessage(Guild guild, InteractionH
String headsUpPattern = "%s please have a look, thanks.";
String headsUpWithoutRole = headsUpPattern.formatted("");
String headsUpWithRole = headsUpPattern.formatted(helperRole.orElseThrow().getAsMention());
return action.flatMap(any -> helpThread.sendMessage(headsUpWithoutRole)
return action.flatMap(_ -> helpThread.sendMessage(headsUpWithoutRole)
.flatMap(message -> message.editMessage(headsUpWithRole)));
}

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

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

Expand All @@ -206,7 +207,7 @@ private void closeThread(SlashCommandInteractionEvent event, ThreadChannel helpT
.setColor(HelpSystemHelper.AMBIENT_COLOR)
.build();

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

private void resetActivity(SlashCommandInteractionEvent event, ThreadChannel helpThread) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ private boolean wasThreadAlreadyHandled(long threadChannelId) {
// the threads we already handled
Instant now = Instant.now();
// NOTE It is necessary to do the "check if exists, otherwise insert" atomic
Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, any -> now);
Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, _ -> now);
return createdAt != now;
}

private void handleHelpThreadCreated(ThreadChannel threadChannel) {
threadChannel.retrieveStartMessage().flatMap(message -> {
registerThreadDataInDB(message, threadChannel);
return sendHelperHeadsUp(threadChannel)
.flatMap(any -> HelpThreadCreatedListener.isContextSufficient(message),
any -> createAIResponse(threadChannel, message))
.flatMap(any -> pinOriginalQuestion(message));
.flatMap(_ -> HelpThreadCreatedListener.isContextSufficient(message),
_ -> createAIResponse(threadChannel, message))
.flatMap(_ -> pinOriginalQuestion(message));
}).queue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
}

if (messageHasNoMediaAttached(message)) {
message.delete().flatMap(any -> dmUser(message)).queue(any -> {
message.delete().flatMap(_ -> dmUser(message)).queue(_ -> {
}, failure -> tempNotifyUserInChannel(message));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private boolean handleIsOnCooldown(MessageContextInteractionEvent event) {
return true;
}

@SuppressWarnings("squid:S2259")
private boolean isAuthorOnCooldown(long userId) {
return Optional.ofNullable(authorToLastReportInvocation.getIfPresent(userId))
.map(sinceCommandInvoked -> sinceCommandInvoked.plus(COOLDOWN_DURATION_VALUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
// Has been handled if original message was deleted by now.
// Deleted messages cause retrieveMessageById to fail.
Consumer<Message> notHandledAction =
any -> transferFlow(event, channelId, authorId, messageId);
_ -> transferFlow(event, channelId, authorId, messageId);

Consumer<Throwable> handledAction = failure -> {
if (failure instanceof ErrorResponseException errorResponseException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
}

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

private RestAction<Message> dmUser(Message message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private MessageEmbed createModMailMessage(@Nullable User author, String userMess
.build();
}

@SuppressWarnings("squid:S2259")
private boolean isChannelOnCooldown(long userId) {
return Optional.ofNullable(authorToLastModMailInvocation.getIfPresent(userId))
.map(sinceCommandInvoked -> sinceCommandInvoked.plus(COOLDOWN_DURATION_VALUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void dmUser(MessageReceivedEvent event) {
}

private void dmUser(Guild guild, long userId, JDA jda) {
jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(any -> {
jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(_ -> {
}, failure -> logger.debug(
"Unable to send dm message to user {} in guild {} to inform them about a scam message being blocked",
userId, guild.getId(), failure));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Failed to send a reminder with (authorID '{}') skipping it. This can be due to a

int failureAttempts = pendingReminder.getFailureAttempts() + 1;
Instant remindAt = Instant.now().plus(1, ChronoUnit.MINUTES);
database.write(any -> {
database.write(_ -> {
pendingReminder.setRemindAt(remindAt);
pendingReminder.setFailureAttempts(failureAttempts);
pendingReminder.insert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static CompletableFuture<List<LinkPreview>> createLinkPreviews(List<Strin
.toList();

var allDoneTask = CompletableFuture.allOf(tasks.toArray(CompletableFuture[]::new));
return allDoneTask.thenApply(any -> extractResults(tasks)).exceptionally(e -> {
return allDoneTask.thenApply(_ -> extractResults(tasks)).exceptionally(e -> {
logger.error("Unknown error during link preview creation", e);
return List.of();
});
Expand Down Expand Up @@ -184,6 +184,7 @@ private static Optional<String> parseMetaProperty(Document doc, String metaPrope
.filter(Predicate.not(String::isBlank));
}

@SuppressWarnings("squid:S2259")
private static Optional<String> selectFirstMetaTag(Document doc, String key, String value) {
return Optional.ofNullable(doc.selectFirst("meta[%s=%s]".formatted(key, value)))
.map(element -> element.attr("content"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ final class SlashCommandAdapterTest {
UserInteractionType.SLASH_COMMAND.getPrefix() + NAME;
private static final String DESCRIPTION = "Foo command";
private static final CommandVisibility VISIBILITY = CommandVisibility.GUILD;
private static final int UNIQUE_ID_ITERATIONS = 20;

static SlashCommandAdapter createAdapter() {
// noinspection AnonymousInnerClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.togetherjava.tjbot.jda;

import com.fasterxml.jackson.databind.ObjectMapper;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
Expand Down Expand Up @@ -67,7 +66,6 @@
* </pre>
*/
public final class ButtonClickEventBuilder {
private static final ObjectMapper JSON = new ObjectMapper();
private final JdaTester jdaTester;
private final Supplier<? extends ButtonInteractionEvent> mockEventSupplier;
private final UnaryOperator<Message> mockMessageOperator;
Expand Down
17 changes: 10 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
plugins {
id 'java'
id "com.diffplug.spotless" version "7.0.3"
id "com.diffplug.spotless" version "7.0.4"
id "org.sonarqube" version "6.2.0.5505"
id "name.remal.sonarlint" version "4.2.2"
id "name.remal.sonarlint" version "5.1.10"
}
repositories {
mavenCentral()
}

group 'org.togetherjava'
version '1.0-SNAPSHOT'

ext {
jooqVersion = '3.20.4'
jacksonVersion = '2.19.0'
chatGPTVersion = '0.18.0'
jooqVersion = '3.20.5'
jacksonVersion = '2.19.1'
chatGPTVersion = '0.18.2'
}

// Skips sonarlint during the build, useful for testing purposes.
Expand Down Expand Up @@ -55,15 +58,15 @@ subprojects {
java {
toolchain {
// Nails the Java-Version of every Subproject
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(24)
}
}

// sonarlint configuration, not to be confused with sonarqube/sonarcloud.
sonarLint {
rules {
disable(
'java:S1135' // Disables "Track uses of "TO-DO" tags" rule.
'java:S1135', // Disables "Track uses of "TO-DO" tags" rule.
)
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading
Loading