@@ -411,21 +411,12 @@ public Request setProxyScheme(String proxyScheme) {
411
411
* options directly in the optons-set using {@link #getOptions()}.
412
412
* </p>
413
413
* <p>
414
- * Note: if the URI contains a hostname, a DNS lookup may be used to
415
- * resolve the address. That may block for a unknown time. To prevent from
416
- * that, the address may be resolved ahead by {@link InetAddress#getByName(String)}.
414
+ * Note: if the URI contains a hostname, a DNS lookup may be used to resolve
415
+ * the address. That may block for a unknown time. To prevent from that, the
416
+ * address may be resolved ahead by {@link InetAddress#getByName(String)}.
417
417
* </p>
418
- * Note: if uri-path or uri-query option was set explicitly before, they are
419
- * not cleaned up, if the URI doesn't contain that part. e.g.
420
- * {@code request.getOptions().setUriQuery("param=2")} and
421
- * {@code request.setURI("coap://host/path")} results in
422
- * {@code "coap://host/path?param=2"}. But
423
- * {@code request.getOptions().setUriQuery("param=2")} and
424
- * {@code request.setURI("coap://host/path?mark")} results in
425
- * {@code "coap://host/path?mark"}.
426
- *
427
- * That will be removed in the next major version! Don't set uri-path or
428
- * uri-query options before the URI!
418
+ * Note: since 3.3, uri-path or uri-query options, if required, must be set
419
+ * after the URI! The URI will clean them, if not contained in the URI.
429
420
*
430
421
* Provides a fluent API to chain setters.
431
422
*
@@ -473,17 +464,8 @@ public Request setURI(final String uri) {
473
464
* resolve the address. That may block for a unknown time. To prevent from
474
465
* that, the address may be resolved ahead by {@link InetAddress#getByName(String)}.
475
466
* <p>
476
- * Note: if uri-path or uri-query option was set explicitly before, they are
477
- * not cleaned up, if the URI doesn't contain that part. e.g.
478
- * {@code request.getOptions().setUriQuery("param=2")} and
479
- * {@code request.setURI("coap://host/path")} results in
480
- * {@code "coap://host/path?param=2"}. But
481
- * {@code request.getOptions().setUriQuery("param=2")} and
482
- * {@code request.setURI("coap://host/path?mark")} results in
483
- * {@code "coap://host/path?mark"}.
484
- *
485
- * That will be removed in the next major version! Don't set uri-path or
486
- * uri-query options before the URI!
467
+ * Note: since 3.3, uri-path or uri-query options, if required, must be set
468
+ * after the URI! The URI will clean them, if not contained in the URI.
487
469
*
488
470
* Provides a fluent API to chain setters.
489
471
*
@@ -537,17 +519,8 @@ public Request setURI(final URI uri) {
537
519
* strict proxy/CoAP URI exclusion for backwards compatibility, set the
538
520
* options directly in the optons-set using {@link #getOptions()}.
539
521
* </p>
540
- * Note: if uri-path or uri-query option was set explicitly before, they are
541
- * not cleaned up, if the URI doesn't contain that part. e.g.
542
- * {@code request.getOptions().setUriQuery("param=2")} and
543
- * {@code request.setURI("coap://host/path")} results in
544
- * {@code "coap://host/path?param=2"}. But
545
- * {@code request.getOptions().setUriQuery("param=2")} and
546
- * {@code request.setURI("coap://host/path?mark")} results in
547
- * {@code "coap://host/path?mark"}.
548
- *
549
- * That will be removed in the next major version! Don't set uri-path or
550
- * uri-query options before the URI!
522
+ * Note: since 3.3, uri-path or uri-query options, if required, must be set
523
+ * after the URI! The URI will clean them, if not contained in the URI.
551
524
*
552
525
* Provides a fluent API to chain setters.
553
526
*
@@ -620,7 +593,6 @@ private void setOptionsInternal(URI uri, InetSocketAddress destination, boolean
620
593
throw new NullPointerException ("destination address must not be null!" );
621
594
}
622
595
OptionSet options = getOptions ();
623
- boolean explicitUriOption = options .hasExplicitUriOptions ();
624
596
String host = uri .getHost ();
625
597
626
598
if (host != null ) {
@@ -670,19 +642,16 @@ private void setOptionsInternal(URI uri, InetSocketAddress destination, boolean
670
642
String path = uri .getPath ();
671
643
if (path != null && path .length () > 1 ) {
672
644
options .setUriPath (path );
673
- } else if (! explicitUriOption ) {
645
+ } else {
674
646
options .clearUriPath ();
675
647
}
676
648
// set Uri-Query options
677
649
String query = uri .getQuery ();
678
650
if (query != null ) {
679
651
options .setUriQuery (query );
680
- } else if (! explicitUriOption ) {
652
+ } else {
681
653
options .clearUriQuery ();
682
654
}
683
- if (!explicitUriOption ) {
684
- options .resetExplicitUriOptions ();
685
- }
686
655
}
687
656
688
657
/**
0 commit comments