From ae503985bb5219733a26069c730c679ab8d7b4f9 Mon Sep 17 00:00:00 2001 From: robm Date: Fri, 1 Aug 2014 15:36:23 +0100 Subject: [PATCH] 8031435: Ftp download does not work properly for ftp user without password Reviewed-by: chegar --- .../classes/sun/net/www/protocol/ftp/FtpURLConnection.java | 2 +- test/sun/net/ftp/FtpURL.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java index ee7684deb..d787ab3df 100644 --- a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java @@ -301,7 +301,7 @@ public class FtpURLConnection extends URLConnection { throw new IOException(fe); } try { - ftp.login(user, password.toCharArray()); + ftp.login(user, password == null ? null : password.toCharArray()); } catch (sun.net.ftp.FtpProtocolException e) { ftp.close(); // Backward compatibility diff --git a/test/sun/net/ftp/FtpURL.java b/test/sun/net/ftp/FtpURL.java index 117913f6a..64c4e8fc8 100644 --- a/test/sun/net/ftp/FtpURL.java +++ b/test/sun/net/ftp/FtpURL.java @@ -483,7 +483,7 @@ public class FtpURL { // Now let's check the URL handler - url = new URL("ftp://user2:@localhost:" + port + "/%2Fusr/bin;type=d"); + url = new URL("ftp://user2@localhost:" + port + "/%2Fusr/bin;type=d"); con = url.openConnection(); in = new BufferedReader(new InputStreamReader(con.getInputStream())); do { -- GitLab