Skip to content

Commit

Permalink
NUTCH-2852 SpotBugs: Method invokes System.exit(...)
Browse files Browse the repository at this point in the history
- remove all calls of System.exit(...) in methods
  except main(args) of various "checker" tools
  • Loading branch information
sebastian-nagel committed Sep 30, 2023
1 parent 45c9de3 commit 417b877
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/java/org/apache/nutch/indexer/IndexingFiltersChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public int run(String[] args) throws Exception {
// Print help when no args given
if (args.length < 1) {
System.err.println(usage);
System.exit(-1);
return -1;
}

// read property "doIndex" for back-ward compatibility
Expand Down Expand Up @@ -126,7 +126,7 @@ public int run(String[] args) throws Exception {
} else if (i != args.length - 1) {
System.err.println("ERR: Not a recognized argument: " + args[i]);
System.err.println(usage);
System.exit(-1);
return -1;
} else {
url = args[i];
}
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/nutch/net/URLFilterChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int run(String[] args) throws Exception {
// Print help when no args given
if (args.length < 1) {
System.err.println(usage);
System.exit(-1);
return -1;
}

int numConsumed;
Expand All @@ -53,7 +53,7 @@ public int run(String[] args) throws Exception {
} else {
System.err.println("ERROR: Not a recognized argument: " + args[i]);
System.err.println(usage);
System.exit(-1);
return -1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/nutch/net/URLNormalizerChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public int run(String[] args) throws Exception {
// Print help when no args given
if (args.length < 1) {
System.err.println(usage);
System.exit(-1);
return -1;
}

int numConsumed;
Expand All @@ -58,7 +58,7 @@ public int run(String[] args) throws Exception {
} else {
System.err.println("ERROR: Not a recognized argument: " + args[i]);
System.err.println(usage);
System.exit(-1);
return -1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/nutch/parse/ParserChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public int run(String[] args) throws Exception {
// Print help when no args given
if (args.length < 1) {
System.err.println(usage);
System.exit(-1);
return -1;
}

// initialize plugins early to register URL stream handlers to support
Expand Down Expand Up @@ -138,7 +138,7 @@ public int run(String[] args) throws Exception {
} else if (i != args.length - 1) {
System.err.println("ERR: Not a recognized argument: " + args[i]);
System.err.println(usage);
System.exit(-1);
return -1;
} else {
url = args[i];
}
Expand Down
9 changes: 4 additions & 5 deletions src/java/org/apache/nutch/util/AbstractChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ protected int parseArgs(String[] args, int i) {
protected int run() throws Exception {
// In listening mode?
if (tcpPort != -1) {
processTCP(tcpPort);
return 0;
return processTCP(tcpPort);
} else if (stdin) {
return processStdin();
}
Expand Down Expand Up @@ -104,7 +103,7 @@ protected int processStdin() throws Exception {

// Open TCP socket and process input
@SuppressWarnings("resource")
protected void processTCP(int tcpPort) throws Exception {
protected int processTCP(int tcpPort) throws Exception {
ServerSocket server = null;

try {
Expand All @@ -113,7 +112,7 @@ protected void processTCP(int tcpPort) throws Exception {
LOG.info(server.toString());
} catch (Exception e) {
LOG.error("Could not listen on port " + tcpPort, e);
System.exit(-1);
return -1;
}

while(true){
Expand All @@ -124,7 +123,7 @@ protected void processTCP(int tcpPort) throws Exception {
thread.start();
} catch (Exception e) {
LOG.error("Accept failed: " + tcpPort, e);
System.exit(-1);
return -1;
}
}
}
Expand Down

0 comments on commit 417b877

Please sign in to comment.