Throw RuntimeException to stop the POMAnalyzer plug-in when there is a connection exception due to the many CLOSE_WAIT connections
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.net.ConnectException;
import java.sql.Timestamp;
import java.util.Collections;
import java.util.List;
@@ -164,6 +165,12 @@ public class POMAnalyzerPlugin extends Plugin {
logger.info("Extracted parent coordinate from " + product);
} catch (RuntimeException | IOException e) {
logger.error("Error extracting data for " + product, e);
+ // After downloading ~50-60K POMs, there will be a lot of CLOSE_WAIT connections,
+ // at some point the plug-in runs out of source ports to use. Therefore, we need to throw an exception and crash so that
+ // Kubernetes will restart the plug-in to kill CLOSE_WAIT connections.
+ if (e.getClass().getCanonicalName().equals(ConnectException.class.getCanonicalName())) {
+ throw new RuntimeException ("Network exception due to many CLOSE_WAIT connections");
+ }
this.pluginError = e;
MavenUtilities.getRepos().remove(artifactRepository);
return;
