Skip to content

Commit

Permalink
Create URL from URI
Browse files Browse the repository at this point in the history
URL constructors deprecated in Java 20.
  • Loading branch information
acogoluegnes committed Aug 28, 2023
1 parent b1f1e26 commit 7c0d6b4
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rabbitmq.client.TrustEverythingTrustManager;

import java.net.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import javax.net.ssl.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -230,7 +228,7 @@ protected Token retrieveToken() {
}
byte[] postData = urlParameters.toString().getBytes(StandardCharsets.UTF_8);
int postDataLength = postData.length;
URL url = new URL(tokenEndpointUri);
URL url = new URI(tokenEndpointUri).toURL();

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

Expand All @@ -256,7 +254,7 @@ protected Token retrieveToken() {
checkContentType(conn.getHeaderField("content-type"));

return parseToken(extractResponseBody(conn.getInputStream()));
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
throw new OAuthTokenManagementException("Error while retrieving OAuth 2 token", e);
}
}
Expand Down

0 comments on commit 7c0d6b4

Please sign in to comment.