Skip to content

Commit 2b0034b

Browse files
Bump Java Version to 20 (#902)
* 19 -> 20 * change deprecated stuff * make sonar happy
1 parent c556a05 commit 2b0034b

File tree

13 files changed

+32
-29
lines changed

13 files changed

+32
-29
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: 19
6+
JAVA_VERSION: 20
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: 19
11+
JAVA_VERSION: 20
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: 19
10+
JAVA_VERSION: 20
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: 19
6+
JAVA_VERSION: 20
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: 19
13+
JAVA_VERSION: 20
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-19-ff696c)
4+
![Java](https://img.shields.io/badge/Java-20-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/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repositories {
1818
var outputImage = 'togetherjava.org:5001/togetherjava/tjbot:' + System.getenv('BRANCH_NAME') ?: 'latest'
1919

2020
jib {
21-
from.image = 'eclipse-temurin:19'
21+
from.image = 'eclipse-temurin:20'
2222
to {
2323
image = outputImage
2424
auth {

application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.*;
1212
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error;
1313

14-
import java.awt.Color;
14+
import java.awt.*;
1515
import java.awt.image.BufferedImage;
1616
import java.io.IOException;
17-
import java.io.UncheckedIOException;
1817
import java.net.HttpURLConnection;
18+
import java.net.URISyntaxException;
1919
import java.net.http.HttpResponse;
2020
import java.util.*;
21+
import java.util.List;
2122
import java.util.function.Function;
2223
import java.util.stream.Collectors;
2324

@@ -169,7 +170,7 @@ private HandlerResponse handleSuccessfulResponse(QueryResult queryResult) {
169170
for (SubPod subPod : pod.getSubPods()) {
170171
try {
171172
images.add(WolframAlphaImages.renderSubPod(subPod));
172-
} catch (UncheckedIOException e) {
173+
} catch (IOException | URISyntaxException e) {
173174
LOGGER.error(
174175
"Failed to render sub pod (title: '{}') from pod (title: '{}') from the WolframAlpha response (for query: '{}')",
175176
subPod.getTitle(), pod.getTitle(), query, e);

application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
import javax.imageio.ImageIO;
77

8-
import java.awt.Color;
9-
import java.awt.Font;
10-
import java.awt.Graphics;
8+
import java.awt.*;
119
import java.awt.font.FontRenderContext;
1210
import java.awt.geom.AffineTransform;
1311
import java.awt.geom.Rectangle2D;
@@ -16,7 +14,8 @@
1614
import java.io.ByteArrayOutputStream;
1715
import java.io.IOException;
1816
import java.io.UncheckedIOException;
19-
import java.net.URL;
17+
import java.net.URI;
18+
import java.net.URISyntaxException;
2019
import java.util.ArrayList;
2120
import java.util.Collection;
2221
import java.util.List;
@@ -55,7 +54,7 @@ static BufferedImage renderTitle(String title) {
5554
return image;
5655
}
5756

58-
static BufferedImage renderSubPod(SubPod subPod) {
57+
static BufferedImage renderSubPod(SubPod subPod) throws IOException, URISyntaxException {
5958
WolframAlphaImage sourceImage = subPod.getImage();
6059

6160
int widthPx = sourceImage.getWidth() + 2 * IMAGE_MARGIN_PX;
@@ -65,12 +64,9 @@ static BufferedImage renderSubPod(SubPod subPod) {
6564
new BufferedImage(widthPx, heightPx, BufferedImage.TYPE_4BYTE_ABGR);
6665
Graphics graphics = destinationImage.getGraphics();
6766

68-
try {
69-
graphics.drawImage(ImageIO.read(new URL(sourceImage.getSource())), IMAGE_MARGIN_PX,
70-
IMAGE_MARGIN_PX, null);
71-
} catch (IOException e) {
72-
throw new UncheckedIOException(e);
73-
}
67+
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()), IMAGE_MARGIN_PX,
68+
IMAGE_MARGIN_PX, null);
69+
7470

7571
return destinationImage;
7672
}

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ subprojects {
6565
options.encoding = 'UTF-8'
6666

6767
// Nails the Java-Version of every Subproject
68-
sourceCompatibility = JavaVersion.VERSION_19
69-
targetCompatibility = JavaVersion.VERSION_19
68+
sourceCompatibility = JavaVersion.VERSION_20
69+
targetCompatibility = JavaVersion.VERSION_20
7070
}
7171

7272
compileJava(compileTasks)

gradle/wrapper/gradle-wrapper.jar

2.06 KB
Binary file not shown.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

+10-5
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
@@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
200205
# Collect all arguments for the java command;
201206
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202207
# shell script including quotes and variable substitutions, so put them in

0 commit comments

Comments
 (0)