Skip to content

Commit abb4464

Browse files
committed
Create URL from URI
URL constructors deprecated in Java 20. (cherry picked from commit 7c0d6b4)
1 parent 817417e commit abb4464

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/com/rabbitmq/client/impl/OAuth2ClientCredentialsGrantCredentialsProvider.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
import com.fasterxml.jackson.databind.ObjectMapper;
1919
import com.rabbitmq.client.TrustEverythingTrustManager;
2020

21+
import java.net.*;
2122
import java.util.concurrent.atomic.AtomicReference;
2223
import java.util.function.Function;
2324
import javax.net.ssl.*;
2425
import java.io.*;
25-
import java.net.HttpURLConnection;
26-
import java.net.URL;
27-
import java.net.URLEncoder;
2826
import java.nio.charset.StandardCharsets;
2927
import java.security.KeyManagementException;
3028
import java.security.NoSuchAlgorithmException;
@@ -230,7 +228,7 @@ protected Token retrieveToken() {
230228
}
231229
byte[] postData = urlParameters.toString().getBytes(StandardCharsets.UTF_8);
232230
int postDataLength = postData.length;
233-
URL url = new URL(tokenEndpointUri);
231+
URL url = new URI(tokenEndpointUri).toURL();
234232

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

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

258256
return parseToken(extractResponseBody(conn.getInputStream()));
259-
} catch (IOException e) {
257+
} catch (IOException | URISyntaxException e) {
260258
throw new OAuthTokenManagementException("Error while retrieving OAuth 2 token", e);
261259
}
262260
}

0 commit comments

Comments
 (0)