Skip to content

Commit ed6487a

Browse files
authored
build(java)!: update to Java 21 (#7)
1 parent 0d9b0da commit ed6487a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

library/src/main/java/dev/andstuff/kraken/api/ApiRequest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.io.OutputStreamWriter;
55
import java.io.UnsupportedEncodingException;
66
import java.net.MalformedURLException;
7+
import java.net.URI;
8+
import java.net.URISyntaxException;
79
import java.net.URL;
810
import java.util.Map;
911
import java.util.Map.Entry;
@@ -106,7 +108,9 @@ public JsonNode execute() throws IOException {
106108
return OBJECT_MAPPER.readTree(connection.getInputStream());
107109
}
108110
finally {
109-
connection.disconnect();
111+
if (connection != null) {
112+
connection.disconnect();
113+
}
110114
}
111115
}
112116

@@ -115,18 +119,21 @@ public JsonNode execute() throws IOException {
115119
*
116120
* @param method the API method
117121
* @return the path of the request taking the method into account
118-
* @throws MalformedURLException if the request URL could not be created
119-
* with the method name
120122
*/
121-
public String setMethod(KrakenApi.Method method) throws MalformedURLException {
123+
public String setMethod(KrakenApi.Method method) {
122124

123125
if (method == null) {
124126
throw new IllegalArgumentException(ERROR_NULL_METHOD);
125127
}
126128

127129
isPublic = method.isPublic;
128-
url = new URL((isPublic ? PUBLIC_URL : PRIVATE_URL) + method.name);
129-
return url.getPath();
130+
try {
131+
url = new URI((isPublic ? PUBLIC_URL : PRIVATE_URL) + method.name).toURL();
132+
return url.getPath();
133+
}
134+
catch (MalformedURLException | URISyntaxException e) {
135+
throw new IllegalStateException("Could not set method URL", e);
136+
}
130137
}
131138

132139
/**

pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@
4646
</issueManagement>
4747

4848
<properties>
49+
<maven.compiler.release>21</maven.compiler.release>
4950
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
50-
<maven.compiler.source>1.8</maven.compiler.source>
51-
<maven.compiler.target>1.8</maven.compiler.target>
52-
<maven.compiler.target>8</maven.compiler.target>
5351

5452
<!-- Third-party dependencies -->
5553
<jackson.version>2.16.1</jackson.version>

0 commit comments

Comments
 (0)