diennea / carapaceproxy

A Distributed Java Reverse Proxy
Apache License 2.0
24 stars 8 forks source link

Deprecation warnings #509

Closed NiccoMlt closed 3 weeks ago

NiccoMlt commented 3 weeks ago

new URL constructor is deprecated since Java 20:

/**

...

 * <h2><a id="constructor-deprecation"></a>Constructing instances of {@code URL}</h2>
 *
 * The {@code java.net.URL} constructors are deprecated.
 * Developers are encouraged to use {@link URI java.net.URI} to parse
 * or construct a {@code URL}. In cases where an instance of {@code
 * java.net.URL} is needed to open a connection, {@link URI} can be used
 * to construct or parse the URL string, possibly calling {@link
 * URI#parseServerAuthority()} to validate that the authority component
 * can be parsed as a server-based authority, and then calling
 * {@link URI#toURL()} to create the {@code URL} instance.
 * <p>
 * The URL constructors are specified to throw
 * {@link MalformedURLException} but the actual parsing/validation
 * that is performed is implementation dependent. Some parsing/validation
 * may be delayed until later, when the underlying {@linkplain
 * URLStreamHandler stream handler's implementation} is called.
 * Being able to construct an instance of {@code URL} doesn't
 * provide any guarantee about its conformance to the URL
 * syntax specification.
 * <p>
 * The URL class does not itself encode or decode any URL components
 * according to the escaping mechanism defined in RFC2396. It is the
 * responsibility of the caller to encode any fields, which need to be
 * escaped prior to calling URL, and also to decode any escaped fields,
 * that are returned from URL. Furthermore, because URL has no knowledge
 * of URL escaping, it does not recognise equivalence between the encoded
 * or decoded form of the same URL. For example, the two URLs:<br>
 * <pre>    http://foo.com/hello world/ and http://foo.com/hello%20world</pre>
 * would be considered not equal to each other.
 * <p>
 * Note, the {@link java.net.URI} class does perform escaping of its
 * component fields in certain circumstances. The recommended way
 * to manage the encoding and decoding of URLs is to use {@link java.net.URI},
 * and to convert between these two classes using {@link #toURI()} and
 * {@link URI#toURL()}.
 * <p>
 * The {@link URLEncoder} and {@link URLDecoder} classes can also be
 * used, but only for HTML form encoding, which is not the same
 * as the encoding scheme defined in RFC2396.
 *
 * @apiNote
 *
 * <a id="integrity"></a>
 * Applications working with file paths and file URIs should take great
 * care to use the appropriate methods to convert between the two.
 * The {@link Path#of(URI)} factory method and the {@link File#File(URI)}
 * constructor can be used to create {@link Path} or {@link File}
 * objects from a file URI. {@link Path#toUri()} and {@link File#toURI()}
 * can be used to create a {@link URI} from a file path, which can be
 * converted to URL using {@link URI#toURL()}.
 * Applications should never try to {@linkplain #URL(String, String, String)
 * construct} or {@linkplain #URL(String) parse} a {@code URL}
 * from the direct string representation of a {@code File} or {@code Path}
 * instance.
 * <p>
 * Before constructing a {@code URL} from a {@code URI}, and depending
 * on the protocol involved, applications should consider validating
 * whether the URI authority {@linkplain URI#parseServerAuthority()
 * can be parsed as server-based}.
 * <p>
 * Some components of a URL or URI, such as <i>userinfo</i>, may
 * be abused to construct misleading URLs or URIs. Applications
 * that deal with URLs or URIs should take into account
 * the recommendations advised in <a
 * href="https://tools.ietf.org/html/rfc3986#section-7">RFC3986,
 * Section 7, Security Considerations</a>.
 * <p>
 * All {@code URL} constructors may throw {@link MalformedURLException}.
 * In particular, if the underlying {@link URLStreamHandler}
 * implementation rejects, or is known to reject, any of the parameters,
 * {@link MalformedURLException} may be thrown.
 * Typically, a constructor that calls the stream handler's {@linkplain
 * URLStreamHandler#parseURL(URL, String, int, int) parseURL method} may
 * throw {@code MalformedURLException} if the underlying stream handler
 * implementation of that method throws {@code IllegalArgumentException}.
 * However, which checks are performed, or not, by the stream handlers
 * is implementation dependent, and callers should not rely on such
 * checks for full URL validation.
 *

...

 */

See https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/URL.html