You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by sn...@apache.org on 2017/12/05 11:10:07 UTC
[nutch] 01/03: This suggested change seems to work.
MalformedURLExceptions no longer occur.
This is an automated email from the ASF dual-hosted git repository.
snagel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nutch.git
commit b4d00e3714d02d45c7ec309182736cf22c28c77c
Author: Hiran Chaudhuri <hi...@mail.de>
AuthorDate: Fri Nov 10 00:16:18 2017 +0100
This suggested change seems to work. MalformedURLExceptions no longer occur.
---
.../src/java/org/apache/nutch/protocol/ftp/Ftp.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
index 84aa823..ae73941 100644
--- a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
+++ b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
@@ -36,6 +36,7 @@ import org.apache.nutch.protocol.ProtocolStatus;
import crawlercommons.robots.BaseRobotRules;
import java.lang.invoke.MethodHandles;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.io.IOException;
@@ -142,7 +143,16 @@ public class Ftp implements Protocol {
} else if (code >= 300 && code < 400) { // handle redirect
if (redirects == MAX_REDIRECTS)
throw new FtpException("Too many redirects: " + url);
- u = new URL(response.getHeader("Location"));
+
+ String loc = response.getHeader("Location");
+ try {
+ u = new URL(u, loc);
+ }
+ catch(MalformedURLException mue) {
+ LOG.error("Could not create redirectURL for {} with {}", url, loc);
+ throw mue;
+ }
+
redirects++;
if (LOG.isTraceEnabled()) {
LOG.trace("redirect to " + u);
@@ -152,6 +162,7 @@ public class Ftp implements Protocol {
}
}
} catch (Exception e) {
+ LOG.error("Could not get protocol output for {}", url, e);
return new ProtocolOutput(null, new ProtocolStatus(e));
}
}
--
To stop receiving notification emails like this one, please contact
"commits@nutch.apache.org" <co...@nutch.apache.org>.