[ 
https://issues.apache.org/jira/browse/NUTCH-2321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326452#comment-16326452
 ] 

ASF GitHub Bot commented on NUTCH-2321:
---------------------------------------

lewismc closed pull request #272: fix for NUTCH-2321 contributed by Jurian 
Broertjes
URL: https://github.com/apache/nutch/pull/272
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/java/org/apache/nutch/util/AbstractChecker.java 
b/src/java/org/apache/nutch/util/AbstractChecker.java
index 842487923..4ff52df92 100644
--- a/src/java/org/apache/nutch/util/AbstractChecker.java
+++ b/src/java/org/apache/nutch/util/AbstractChecker.java
@@ -131,11 +131,17 @@ protected void processTCP(int tcpPort) throws Exception {
 
     public void run() {
       if (keepClientCnxOpen) {
-        while (true) { // keep connection open until closes
-          readWrite();
+        try {
+          while (readWrite()) {} // keep connection open until it closes
+        } catch(Exception e) {
+          LOG.error("Read/Write failed: ", e);
         }
       } else {
-        readWrite();
+        try {
+          readWrite();
+        } catch(Exception e) {
+          LOG.error("Read/Write failed: ", e);
+        }
         
         try { // close ourselves
           client.close();
@@ -145,27 +151,25 @@ public void run() {
       }
     }
     
-    protected void readWrite() {
+    protected boolean readWrite() throws Exception {
       String line;
       BufferedReader in = null;
       PrintWriter out = null;
       
-      try {
-        in = new BufferedReader(new 
InputStreamReader(client.getInputStream()));
-      } catch (Exception e) {
-        LOG.error("in or out failed");
-        System.exit(-1);
+      in = new BufferedReader(new InputStreamReader(client.getInputStream()));
+
+      line = in.readLine();
+      if (line == null) {
+        // End of stream
+        return false;
       }
 
-      try {
-        line = in.readLine();
+      if (line.trim().length() > 1) {
         StringBuilder output = new StringBuilder();
         process(line, output);
-        
         
client.getOutputStream().write(output.toString().getBytes(StandardCharsets.UTF_8));
-      } catch (Exception e) {
-        LOG.error("Read/Write failed: " + e);
       }
+      return true;
     }
   }
 }
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Indexing filter checker leaks threads
> -------------------------------------
>
>                 Key: NUTCH-2321
>                 URL: https://issues.apache.org/jira/browse/NUTCH-2321
>             Project: Nutch
>          Issue Type: Bug
>    Affects Versions: 1.12
>            Reporter: Markus Jelsma
>            Assignee: Markus Jelsma
>            Priority: Minor
>             Fix For: 1.15
>
>         Attachments: NUTCH-2321.patch
>
>
> Same issue as NUTCH-2320.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to