|
6 | 6 | import java.io.OutputStreamWriter;
|
7 | 7 | import java.net.HttpURLConnection;
|
8 | 8 | import java.net.MalformedURLException;
|
9 |
| -import java.net.URL; |
| 9 | +import java.net.URI; |
10 | 10 | import java.time.ZoneId;
|
11 | 11 | import java.time.ZonedDateTime;
|
12 | 12 | import java.time.format.DateTimeFormatter;
|
@@ -101,7 +101,9 @@ public static SuccessResponseAndHeaders sendJsonrpcRequest(String url, String co
|
101 | 101 | HttpURLConnection connection = null;
|
102 | 102 | try {
|
103 | 103 | // Open connection to Odoo
|
104 |
| - connection = (HttpURLConnection) new URL(url).openConnection(); |
| 104 | + connection = (HttpURLConnection) URI.create(url) // |
| 105 | + .toURL() // |
| 106 | + .openConnection(); // |
105 | 107 | connection.setConnectTimeout(5000);// 5 secs
|
106 | 108 | connection.setReadTimeout(timeout);// 5 secs
|
107 | 109 | connection.setRequestProperty("Accept-Charset", "US-ASCII");
|
@@ -276,8 +278,9 @@ private static Object executeKw(Credentials creds, String model, String action,
|
276 | 278 | private static Object executeKw(Credentials creds, String model, String action, Object[] arg, Map<String, ?> kw)
|
277 | 279 | throws MalformedURLException, XMLRPCException {
|
278 | 280 | var params = new Object[] { creds.getDatabase(), creds.getUid(), creds.getPassword(), model, action, arg, kw };
|
279 |
| - var client = new XMLRPCClient(new URL(String.format("%s/xmlrpc/2/object", creds.getUrl())), |
280 |
| - XMLRPCClient.FLAGS_NIL); |
| 281 | + var uri = URI.create(String.format("%s/xmlrpc/2/object", creds.getUrl())); |
| 282 | + var client = new XMLRPCClient(uri.toURL(), XMLRPCClient.FLAGS_NIL); |
| 283 | + |
281 | 284 | client.setTimeout(60 /* seconds */);
|
282 | 285 | return client.call("execute_kw", params);
|
283 | 286 | }
|
@@ -557,9 +560,9 @@ protected static byte[] getOdooReport(Credentials credentials, String report, in
|
557 | 560 |
|
558 | 561 | HttpURLConnection connection = null;
|
559 | 562 | try {
|
560 |
| - connection = (HttpURLConnection) new URL( |
561 |
| - credentials.getUrl() + "/report/pdf/" + report + "/" + id + "?session_id=" + session) |
562 |
| - .openConnection(); |
| 563 | + connection = (HttpURLConnection) URI |
| 564 | + .create(credentials.getUrl() + "/report/pdf/" + report + "/" + id + "?session_id=" + session) |
| 565 | + .toURL().openConnection(); |
563 | 566 | connection.setConnectTimeout(5000);
|
564 | 567 | connection.setReadTimeout(5000);
|
565 | 568 | connection.setRequestMethod("GET");
|
|
0 commit comments