Skip to content
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
19 changes: 13 additions & 6 deletions library/src/main/java/dev/andstuff/kraken/api/ApiRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -106,7 +108,9 @@ public JsonNode execute() throws IOException {
return OBJECT_MAPPER.readTree(connection.getInputStream());
}
finally {
connection.disconnect();
if (connection != null) {
connection.disconnect();
}
}
}

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

if (method == null) {
throw new IllegalArgumentException(ERROR_NULL_METHOD);
}

isPublic = method.isPublic;
url = new URL((isPublic ? PUBLIC_URL : PRIVATE_URL) + method.name);
return url.getPath();
try {
url = new URI((isPublic ? PUBLIC_URL : PRIVATE_URL) + method.name).toURL();
return url.getPath();
}
catch (MalformedURLException | URISyntaxException e) {
throw new IllegalStateException("Could not set method URL", e);
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@
</issueManagement>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.target>8</maven.compiler.target>

<!-- Third-party dependencies -->
<jackson.version>2.16.1</jackson.version>
Expand Down