From 8925d61c8723dd6f990a7b5c51514d19a0b7b915 Mon Sep 17 00:00:00 2001 From: ayushaga14 Date: Thu, 19 Sep 2024 16:48:30 +0530 Subject: [PATCH] add timeout values and optimize loop --- .../com/akto/action/JiraIntegrationAction.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java index 5b5c4c2d20..57cd72b833 100644 --- a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; import org.bson.conversions.Bson; @@ -67,7 +68,11 @@ public class JiraIntegrationAction extends UserAction { private final String CREATE_ISSUE_ENDPOINT = "/rest/api/3/issue"; private final String ATTACH_FILE_ENDPOINT = "/attachments"; private static final LoggerMaker loggerMaker = new LoggerMaker(ApiExecutor.class); - private static final OkHttpClient client = CoreHTTPClient.client.newBuilder().build(); + private static final OkHttpClient client = CoreHTTPClient.client.newBuilder() + .connectTimeout(60, TimeUnit.SECONDS) + .readTimeout(60, TimeUnit.SECONDS) + .writeTimeout(60, TimeUnit.SECONDS) + .build(); public String testIntegration() { @@ -104,11 +109,15 @@ public String testIntegration() { for (Object projObj: projects) { BasicDBObject obj = (BasicDBObject) projObj; String key = obj.getString("key"); - loggerMaker.errorAndAddToDb("evaluating issuetype for project key " + key + " ,actualProjId " + projId, LoggerMaker.LogDb.DASHBOARD); + loggerMaker.infoAndAddToDb("evaluating issuetype for project key " + key + " ,actualProjId " + projId, LoggerMaker.LogDb.DASHBOARD); + if (issueType!=null) { + break; + } + if (!key.equalsIgnoreCase(projId)) { continue; } - loggerMaker.errorAndAddToDb("evaluating issuetype for project key " + key + ", project json obj " + obj, LoggerMaker.LogDb.DASHBOARD); + loggerMaker.infoAndAddToDb("evaluating issuetype for project key " + key + ", project json obj " + obj, LoggerMaker.LogDb.DASHBOARD); BasicDBList issueTypes = (BasicDBList) obj.get("issuetypes"); issueType = determineIssueType(issueTypes, "TASK"); loggerMaker.infoAndAddToDb("evaluated issue type for TASK type " + issueType, LoggerMaker.LogDb.DASHBOARD);