Skip to content

Commit 8d904e5

Browse files
authored
CDRIVER-5952 remove deprecated URI API (#1963)
* remove `mongoc_uri_get_service` * remove `mongoc_uri_get_read_prefs` * remove `mongoc_uri_get_ssl`
1 parent 4fa042c commit 8d904e5

8 files changed

+6
-135
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ Unreleased (2.0.0)
104104
* `mongoc_stream_tls_do_handshake` is removed. Use `mongoc_stream_tls_handshake` instead.
105105
* `mongoc_stream_tls_check_cert` is removed. Use `mongoc_stream_tls_handshake` instead.
106106
* `mongoc_stream_tls_new` is removed. Use `mongoc_stream_tls_new_with_hostname` instead.
107+
* Deprecated URI API has been removed:
108+
* `mongoc_uri_get_service` is removed. Use `mongoc_uri_get_srv_hostname` instead.
109+
* `mongoc_uri_get_read_prefs` is removed. Use `mongoc_uri_get_read_prefs_t` instead.
110+
* `mongoc_uri_get_ssl` is removed. Use `mongoc_uri_get_tls` instead.
107111

108112
### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)
109113

src/libmongoc/doc/mongoc_uri_get_read_prefs.rst

-33
This file was deleted.

src/libmongoc/doc/mongoc_uri_get_service.rst

-29
This file was deleted.

src/libmongoc/doc/mongoc_uri_get_ssl.rst

-34
This file was deleted.

src/libmongoc/doc/mongoc_uri_t.rst

-3
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,9 @@ MONGOC_URI_SAFE safe {tr
349349
mongoc_uri_get_options
350350
mongoc_uri_get_password
351351
mongoc_uri_get_read_concern
352-
mongoc_uri_get_read_prefs
353352
mongoc_uri_get_read_prefs_t
354353
mongoc_uri_get_replica_set
355354
mongoc_uri_get_server_monitoring_mode
356-
mongoc_uri_get_service
357-
mongoc_uri_get_ssl
358355
mongoc_uri_get_string
359356
mongoc_uri_get_srv_hostname
360357
mongoc_uri_get_srv_service_name

src/libmongoc/src/mongoc/mongoc-uri.c

-19
Original file line numberDiff line numberDiff line change
@@ -2555,13 +2555,6 @@ mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri)
25552555
}
25562556

25572557

2558-
const char *
2559-
mongoc_uri_get_service (const mongoc_uri_t *uri)
2560-
{
2561-
return mongoc_uri_get_srv_hostname (uri);
2562-
}
2563-
2564-
25652558
/* Initial DNS Seedlist Discovery Spec: `srvServiceName` requires a string value
25662559
* and defaults to "mongodb". */
25672560
static const char *const mongoc_default_srv_service_name = "mongodb";
@@ -2664,13 +2657,6 @@ mongoc_uri_get_string (const mongoc_uri_t *uri)
26642657
}
26652658

26662659

2667-
const bson_t *
2668-
mongoc_uri_get_read_prefs (const mongoc_uri_t *uri)
2669-
{
2670-
BSON_ASSERT (uri);
2671-
return mongoc_read_prefs_get_tags (uri->read_prefs);
2672-
}
2673-
26742660
char *
26752661
mongoc_uri_unescape (const char *escaped_string)
26762662
{
@@ -2824,11 +2810,6 @@ mongoc_uri_get_tls (const mongoc_uri_t *uri) /* IN */
28242810
return false;
28252811
}
28262812

2827-
bool
2828-
mongoc_uri_get_ssl (const mongoc_uri_t *uri) /* IN */
2829-
{
2830-
return mongoc_uri_get_tls (uri);
2831-
}
28322813

28332814
const char *
28342815
mongoc_uri_get_server_monitoring_mode (const mongoc_uri_t *uri)

src/libmongoc/src/mongoc/mongoc-uri.h

-8
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ mongoc_uri_new_for_host_port (const char *hostname, uint16_t port) BSON_GNUC_WAR
108108
MONGOC_EXPORT (const mongoc_host_list_t *)
109109
mongoc_uri_get_hosts (const mongoc_uri_t *uri);
110110

111-
BSON_DEPRECATED_FOR (mongoc_uri_get_srv_hostname)
112-
MONGOC_EXPORT (const char *) mongoc_uri_get_service (const mongoc_uri_t *uri);
113-
114111
MONGOC_EXPORT (const char *)
115112
mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri);
116113

@@ -174,9 +171,6 @@ mongoc_uri_set_option_as_bool (mongoc_uri_t *uri, const char *option, bool value
174171
MONGOC_EXPORT (bool)
175172
mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, const char *option, const char *value);
176173

177-
BSON_DEPRECATED_FOR (mongoc_uri_get_read_prefs_t)
178-
MONGOC_EXPORT (const bson_t *) mongoc_uri_get_read_prefs (const mongoc_uri_t *uri);
179-
180174
MONGOC_EXPORT (const char *)
181175
mongoc_uri_get_replica_set (const mongoc_uri_t *uri);
182176

@@ -219,8 +213,6 @@ mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri, bson_t *properties
219213
MONGOC_EXPORT (bool)
220214
mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri, const bson_t *properties);
221215

222-
BSON_DEPRECATED_FOR (mongoc_uri_get_tls) MONGOC_EXPORT (bool) mongoc_uri_get_ssl (const mongoc_uri_t *uri);
223-
224216
MONGOC_EXPORT (bool)
225217
mongoc_uri_get_tls (const mongoc_uri_t *uri);
226218

src/libmongoc/tests/test-mongoc-uri.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -2351,21 +2351,18 @@ test_mongoc_uri_tls_ssl (const char *tls,
23512351

23522352
bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCertificateKeyFile);
23532353
uri = mongoc_uri_new (url_buffer);
2354-
ASSERT (mongoc_uri_get_ssl (uri));
23552354
ASSERT (mongoc_uri_get_tls (uri));
23562355
mongoc_uri_destroy (uri);
23572356

23582357

23592358
bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCAFile);
23602359
uri = mongoc_uri_new (url_buffer);
2361-
ASSERT (mongoc_uri_get_ssl (uri));
23622360
ASSERT (mongoc_uri_get_tls (uri));
23632361
mongoc_uri_destroy (uri);
23642362

23652363

23662364
bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidCertificates);
23672365
uri = mongoc_uri_new (url_buffer);
2368-
ASSERT (mongoc_uri_get_ssl (uri));
23692366
ASSERT (mongoc_uri_get_tls (uri));
23702367
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false));
23712368
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false));
@@ -2374,7 +2371,6 @@ test_mongoc_uri_tls_ssl (const char *tls,
23742371

23752372
bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidHostnames);
23762373
uri = mongoc_uri_new (url_buffer);
2377-
ASSERT (mongoc_uri_get_ssl (uri));
23782374
ASSERT (mongoc_uri_get_tls (uri));
23792375
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false));
23802376
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false));
@@ -2384,23 +2380,20 @@ test_mongoc_uri_tls_ssl (const char *tls,
23842380
bson_snprintf (
23852381
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile);
23862382
uri = mongoc_uri_new (url_buffer);
2387-
ASSERT (!mongoc_uri_get_ssl (uri));
23882383
ASSERT (!mongoc_uri_get_tls (uri));
23892384
mongoc_uri_destroy (uri);
23902385

23912386

23922387
bson_snprintf (
23932388
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile);
23942389
uri = mongoc_uri_new (url_buffer);
2395-
ASSERT (!mongoc_uri_get_ssl (uri));
23962390
ASSERT (!mongoc_uri_get_tls (uri));
23972391
mongoc_uri_destroy (uri);
23982392

23992393

24002394
bson_snprintf (
24012395
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=true", tls, tlsAllowInvalidCertificates);
24022396
uri = mongoc_uri_new (url_buffer);
2403-
ASSERT (!mongoc_uri_get_ssl (uri));
24042397
ASSERT (!mongoc_uri_get_tls (uri));
24052398
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false));
24062399
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false));
@@ -2410,7 +2403,6 @@ test_mongoc_uri_tls_ssl (const char *tls,
24102403
bson_snprintf (
24112404
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=false", tls, tlsAllowInvalidHostnames);
24122405
uri = mongoc_uri_new (url_buffer);
2413-
ASSERT (!mongoc_uri_get_ssl (uri));
24142406
ASSERT (!mongoc_uri_get_tls (uri));
24152407
ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, true));
24162408
ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true));
@@ -2917,7 +2909,8 @@ test_mongoc_uri_duplicates (void)
29172909
RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_READPREFERENCETAGS
29182910
"=a:x&" MONGOC_URI_READPREFERENCETAGS "=b:y");
29192911
ASSERT_NO_CAPTURED_LOGS (mongoc_uri_get_string (uri));
2920-
bson = mongoc_uri_get_read_prefs (uri);
2912+
rp = mongoc_uri_get_read_prefs_t (uri);
2913+
bson = mongoc_read_prefs_get_tags (rp);
29212914
ASSERT_EQUAL_BSON (tmp_bson ("[{'a': 'x'}, {'b': 'y'}]"), bson);
29222915

29232916
RECREATE_URI (MONGOC_URI_REPLICASET "=a&" MONGOC_URI_REPLICASET "=b");

0 commit comments

Comments
 (0)