You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/06/13 12:48:34 UTC
(maven-wagon) 01/01: Deprecate URL parsing methods in PathUtils in favor of JDK's URI class
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch dep
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git
commit d271317fe394925c1f0ff14a0f92208ac986416d
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Fri Jun 13 08:48:23 2025 -0400
Deprecate URL parsing methods in PathUtils in favor of JDK's URI class
---
.../java/org/apache/maven/wagon/PathUtils.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
index 9c05eba4..5f7e61d7 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
@@ -22,7 +22,12 @@
import java.util.StringTokenizer;
/**
- * Various path (URL) manipulation routines
+ * Various path (URL) manipulation routines. Standard JDK methods in
+ * java.net.URI and java.nio.file.Path should be used instead.
+ * It's not always a direct one-to-one replacement. For instance,
+ * a PathUtils method might return an empty string in a case where the
+ * corresponding JDK method returns null. However, all logic in this
+ * class has been present in the JDK since Java 1.4.
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*
@@ -113,7 +118,9 @@ private static String[] split(final String str, final String separator, final in
*
* @param url the url
* @return the host name
+ * @deprecated replace with {@code new URI(url).getHost()}
*/
+ @Deprecated
public static String host(final String url) {
if (url == null || url.length() == 0) {
return "localhost";
@@ -192,7 +199,9 @@ private static int endOfHostPosition(String host, int pos) {
*
* @param url the url
* @return the host name
+ * @deprecated replace with {@code new URI(url).getScheme()}
*/
+ @Deprecated
public static String protocol(final String url) {
final int pos = url.indexOf(":");
@@ -205,7 +214,9 @@ public static String protocol(final String url) {
/**
* @param url
* @return the port or {@link WagonConstants#UNKNOWN_PORT} if not existent
+ * @deprecated replace with {@code new URI(url).getPort()}
*/
+ @Deprecated
public static int port(String url) {
final String protocol = PathUtils.protocol(url);
@@ -260,8 +271,9 @@ public static int port(String url) {
*
* @param url the repository URL
* @return the basedir of the repository
- * @todo need to URL decode for spaces?
+ * @deprecated replace with {@code new URI(url).getPath()}
*/
+ @Deprecated
public static String basedir(String url) {
String protocol = PathUtils.protocol(url);
@@ -369,6 +381,10 @@ private static String decode(String url) {
return decoded;
}
+ /**
+ * @deprecated replace with {@code new URI(url).getUserInfo()}
+ */
+ @Deprecated
public static String user(String url) {
String host = authorization(url);
int index = host.indexOf('@');
@@ -384,6 +400,10 @@ public static String user(String url) {
return null;
}
+ /**
+ * @deprecated do not store passwords in URLs
+ */
+ @Deprecated
public static String password(String url) {
String host = authorization(url);
int index = host.indexOf('@');