Skip to content

Commit

Permalink
JDK 21 upgrade - code cleanup (#167)
Browse files Browse the repository at this point in the history
* #164 : Master to main changes + start on JDK21

* #164 : Maven - Bumped Lombok for JDK21

* Tweaked maven compiler settings for JDK21.
* Fixed Javadoc earnings in exchange adapters.

* #164 : Maven - Bumped to latest Boot 3.1.10 release

* #164 : Fix new Sonar whine

* #164 : Fix build

* #164 : Update maven build deps

* Also updated maven wrapper.
* Enforced maven 3.8+ and JDK21+

* #164 : Update CI config for JDK 21

* Also updated docs for JDK 17 -> JDK 21

* #164 : Update Docker base image for JDK 21

* #164 : Revert Gradle CI build to JDK 17

* Gradle deps need uplifting...

* #164 : Removed discontinued Coinbase Pro adapter

* See: https://www.coinbase.com/en-gb/blog/hello-advanced-trade-goodbye-coinbase-pro

* #164 : Updated Gradle deps for JDK 21

* Also bump to latest Boot patch version.
* Fix SpotBugs whine.

* #164 : Upgrade to Gradle 8.7 + ignore SpotBugs issue

* #164 : Fix deprecated use of URL constructor
  • Loading branch information
gazbert authored Apr 21, 2024
1 parent 7ddce5b commit be32aa4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -900,10 +902,10 @@ public String toString() {
private ExchangeHttpResponse sendPublicRequestToExchange(String apiMethod)
throws ExchangeNetworkException, TradingApiException {
try {
final URL url = new URL(PUBLIC_API_BASE_URL + apiMethod);
final URL url = new URI(PUBLIC_API_BASE_URL + apiMethod).toURL();
return makeNetworkRequest(url, "GET", null, createHeaderParamMap());

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down Expand Up @@ -986,10 +988,10 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
// payload is JSON for this exchange
requestHeaders.put("Content-Type", "application/json");

final URL url = new URL(AUTHENTICATED_API_URL + apiMethod);
final URL url = new URI(AUTHENTICATED_API_URL + apiMethod).toURL();
return makeNetworkRequest(url, "POST", paramsInJson, requestHeaders);

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
Expand Down Expand Up @@ -754,10 +756,10 @@ public Date deserialize(JsonElement json, Type type, JsonDeserializationContext
private ExchangeHttpResponse sendPublicRequestToExchange(String apiMethod)
throws ExchangeNetworkException, TradingApiException {
try {
final URL url = new URL(API_BASE_URL + apiMethod);
final URL url = new URI(API_BASE_URL + apiMethod).toURL();
return makeNetworkRequest(url, "GET", null, createHeaderParamMap());

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down Expand Up @@ -820,10 +822,10 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
requestHeaders.put("Content-Type", "application/x-www-form-urlencoded");

// MUST have the trailing slash else exchange barfs...
final URL url = new URL(API_BASE_URL + apiMethod + "/");
final URL url = new URI(API_BASE_URL + apiMethod + "/").toURL();
return makeNetworkRequest(url, "POST", postData.toString(), requestHeaders);

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -644,10 +646,10 @@ public String toString() {
private ExchangeHttpResponse sendPublicRequestToExchange(String apiMethod)
throws ExchangeNetworkException, TradingApiException {
try {
final URL url = new URL(PUBLIC_API_BASE_URL + apiMethod);
final URL url = new URI(PUBLIC_API_BASE_URL + apiMethod).toURL();
return makeNetworkRequest(url, "GET", null, createRequestParamMap());

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down Expand Up @@ -739,10 +741,10 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
// payload is JSON for this exchange
requestHeaders.put("Content-Type", "application/json");

final URL url = new URL(AUTHENTICATED_API_URL + apiMethod);
final URL url = new URI(AUTHENTICATED_API_URL + apiMethod).toURL();
return makeNetworkRequest(url, "POST", paramsInJson, requestHeaders);

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import java.math.RoundingMode;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
Expand Down Expand Up @@ -943,10 +945,10 @@ private ExchangeHttpResponse sendPublicRequestToExchange(
requestHeaders.put("Content-Type", "application/x-www-form-urlencoded");
}

final URL url = new URL(PUBLIC_API_BASE_URL + apiMethod + queryString);
final URL url = new URI(PUBLIC_API_BASE_URL + apiMethod + queryString).toURL();
return makeNetworkRequest(url, "GET", null, requestHeaders);

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down Expand Up @@ -1028,10 +1030,10 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
requestHeaders.put("API-Key", key);
requestHeaders.put("API-Sign", signature);

final URL url = new URL(AUTHENTICATED_API_URL + apiMethod);
final URL url = new URI(AUTHENTICATED_API_URL + apiMethod).toURL();
return makeNetworkRequest(url, "POST", postData.toString(), requestHeaders);

} catch (MalformedURLException | NoSuchAlgorithmException e) {
} catch (MalformedURLException | NoSuchAlgorithmException | URISyntaxException e) {
final String errorMsg = UNEXPECTED_IO_ERROR_MSG;
log.error(errorMsg, e);
throw new TradingApiException(errorMsg, e);
Expand Down

0 comments on commit be32aa4

Please sign in to comment.