From 8a0838505a3b6060865f8e244b8e8c4fd85209be Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Thu, 1 Sep 2022 11:16:45 +0530 Subject: [PATCH] All outgoing requests should go through the configured proxy (#14427) Signed-off-by: Shrikant Sharat Kandula Co-authored-by: Aishwarya UR --- app/server/appsmith-interfaces/pom.xml | 19 +++++--- .../com/appsmith/util/WebClientUtils.java | 45 +++++++++++++++++++ .../googleSheetsPlugin/pom.xml | 7 --- .../com/external/config/FileInfoMethod.java | 3 +- .../com/external/config/RowsAppendMethod.java | 3 +- .../external/config/RowsBulkAppendMethod.java | 3 +- .../external/config/RowsBulkUpdateMethod.java | 3 +- .../com/external/config/RowsDeleteMethod.java | 3 +- .../com/external/config/RowsUpdateMethod.java | 3 +- .../external/config/SheetDeleteMethod.java | 3 +- .../external/plugins/GoogleSheetsPlugin.java | 9 ++-- .../external/plugins/commands/Aggregate.java | 2 +- .../com/external/plugins/commands/Count.java | 2 +- .../external/plugins/commands/Distinct.java | 2 +- .../com/external/plugins/commands/Find.java | 4 +- .../com/external/plugins/commands/Insert.java | 4 +- .../appsmith-plugins/mysqlPlugin/pom.xml | 6 --- .../com/external/plugins/RapidApiPlugin.java | 3 +- .../appsmith-plugins/restApiPlugin/pom.xml | 25 ----------- .../connections/OAuth2AuthorizationCode.java | 7 ++- .../connections/OAuth2ClientCredentials.java | 8 ++-- .../com/external/plugins/RestApiPlugin.java | 9 +--- .../java/com/external/plugins/SaasPlugin.java | 5 ++- app/server/appsmith-server/pom.xml | 1 + .../server/configurations/InstanceConfig.java | 4 +- .../server/helpers/GitCloudServicesUtils.java | 4 +- .../com/appsmith/server/helpers/GitUtils.java | 8 +--- .../appsmith/server/helpers/NetworkUtils.java | 4 +- .../ce/ApplicationTemplateServiceCEImpl.java | 11 ++--- .../services/ce/MockDataServiceCEImpl.java | 6 +-- .../services/ce/PluginServiceCEImpl.java | 6 +-- .../ce/AuthenticationServiceCEImpl.java | 18 +++----- .../solutions/ce/PingScheduledTaskCEImpl.java | 8 ++-- .../ce/PluginScheduledTaskCEImpl.java | 6 +-- .../ce/ReleaseNotesServiceCEImpl.java | 4 +- .../DatasourceTriggerSolutionTest.java | 4 +- app/server/reactive-caching/pom.xml | 3 +- deploy/docker/scripts/run-java.sh | 4 +- 38 files changed, 138 insertions(+), 131 deletions(-) create mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/util/WebClientUtils.java diff --git a/app/server/appsmith-interfaces/pom.xml b/app/server/appsmith-interfaces/pom.xml index 82be696650..e1f3e596bf 100644 --- a/app/server/appsmith-interfaces/pom.xml +++ b/app/server/appsmith-interfaces/pom.xml @@ -32,11 +32,6 @@ 3.5.0 - - io.projectreactor - reactor-core - - org.springframework.boot spring-boot-starter-data-mongodb-reactive @@ -129,11 +124,25 @@ org.springframework spring-webflux + io.projectreactor.netty reactor-netty-core provided + + + io.projectreactor.netty + reactor-netty-http + 1.0.17 + + + io.projectreactor + reactor-core + + + + diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/util/WebClientUtils.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/util/WebClientUtils.java new file mode 100644 index 0000000000..8861dd16e5 --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/util/WebClientUtils.java @@ -0,0 +1,45 @@ +package com.appsmith.util; + +import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.netty.http.client.HttpClient; + +public class WebClientUtils { + + private WebClientUtils() { + } + + public static WebClient create() { + return builder() + .build(); + } + + public static WebClient create(String baseUrl) { + return builder() + .baseUrl(baseUrl) + .build(); + } + + private static boolean shouldUseSystemProxy() { + return "true".equals(System.getProperty("java.net.useSystemProxies")) + && (!System.getProperty("http.proxyHost", "").isEmpty() || !System.getProperty("https.proxyHost", "").isEmpty()); + } + + public static WebClient.Builder builder() { + return builder(HttpClient.create()); + } + + public static WebClient.Builder builder(HttpClient httpClient) { + return WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(applyProxyIfConfigured(httpClient))); + } + + private static HttpClient applyProxyIfConfigured(HttpClient httpClient) { + if (shouldUseSystemProxy()) { + httpClient = httpClient.proxyWithSystemProperties(); + } + + return httpClient; + } + +} diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/pom.xml b/app/server/appsmith-plugins/googleSheetsPlugin/pom.xml index 2156ced6da..07cca7937c 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/pom.xml +++ b/app/server/appsmith-plugins/googleSheetsPlugin/pom.xml @@ -161,13 +161,6 @@ test - - io.projectreactor.netty - reactor-netty - 0.9.4.RELEASE - provided - - diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/FileInfoMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/FileInfoMethod.java index 8124d21567..a4f33249e7 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/FileInfoMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/FileInfoMethod.java @@ -3,6 +3,7 @@ package com.external.config; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.http.HttpMethod; @@ -33,7 +34,7 @@ public class FileInfoMethod implements ExecutionMethod, TriggerMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); UriComponentsBuilder uriBuilder = getBaseUriBuilder(this.BASE_SHEETS_API_URL, diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsAppendMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsAppendMethod.java index 533e75d99e..3b68eec91d 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsAppendMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsAppendMethod.java @@ -4,6 +4,7 @@ import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.helpers.PluginUtils; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.external.constants.FieldName; import com.external.domains.RowObject; import com.fasterxml.jackson.core.JsonProcessingException; @@ -82,7 +83,7 @@ public class RowsAppendMethod implements ExecutionMethod, TemplateMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); final RowsGetMethod rowsGetMethod = new RowsGetMethod(this.objectMapper); diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkAppendMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkAppendMethod.java index 6cbb3521d8..bfb7fe8b90 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkAppendMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkAppendMethod.java @@ -3,6 +3,7 @@ package com.external.config; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.external.domains.RowObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; @@ -82,7 +83,7 @@ public class RowsBulkAppendMethod implements ExecutionMethod { */ @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); final RowsGetMethod rowsGetMethod = new RowsGetMethod(this.objectMapper); diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkUpdateMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkUpdateMethod.java index e30c7e056c..5a3f3ef0ab 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkUpdateMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsBulkUpdateMethod.java @@ -3,6 +3,7 @@ package com.external.config; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.external.domains.RowObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; @@ -77,7 +78,7 @@ public class RowsBulkUpdateMethod implements ExecutionMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); final RowsGetMethod rowsGetMethod = new RowsGetMethod(this.objectMapper); diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsDeleteMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsDeleteMethod.java index 6fbaaafa40..3aad442ba1 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsDeleteMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsDeleteMethod.java @@ -3,6 +3,7 @@ package com.external.config; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.http.HttpMethod; @@ -71,7 +72,7 @@ public class RowsDeleteMethod implements ExecutionMethod, TemplateMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); UriComponentsBuilder uriBuilder = getBaseUriBuilder(this.BASE_SHEETS_API_URL, diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsUpdateMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsUpdateMethod.java index 28fa171911..ebdaf60188 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsUpdateMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsUpdateMethod.java @@ -4,6 +4,7 @@ import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.helpers.PluginUtils; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.external.constants.FieldName; import com.external.domains.RowObject; import com.fasterxml.jackson.core.JsonProcessingException; @@ -73,7 +74,7 @@ public class RowsUpdateMethod implements ExecutionMethod, TemplateMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); final RowsGetMethod rowsGetMethod = new RowsGetMethod(this.objectMapper); diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/SheetDeleteMethod.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/SheetDeleteMethod.java index 03281360a2..8f34715a2e 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/SheetDeleteMethod.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/SheetDeleteMethod.java @@ -3,6 +3,7 @@ package com.external.config; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.models.OAuth2; +import com.appsmith.util.WebClientUtils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -42,7 +43,7 @@ public class SheetDeleteMethod implements ExecutionMethod { @Override public Mono executePrerequisites(MethodConfig methodConfig, OAuth2 oauth2) { - WebClient client = WebClient.builder() + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); UriComponentsBuilder uriBuilder = getBaseUriBuilder(this.BASE_SHEETS_API_URL, diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java index 1efa21036e..3ca5741049 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java @@ -16,6 +16,7 @@ import com.appsmith.external.models.TriggerResultDTO; import com.appsmith.external.plugins.BasePlugin; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.external.plugins.SmartSubstitutionInterface; +import com.appsmith.util.WebClientUtils; import com.external.config.ExecutionMethod; import com.external.config.GoogleSheetsMethodStrategy; import com.external.config.MethodConfig; @@ -157,12 +158,10 @@ public class GoogleSheetsPlugin extends BasePlugin { // Convert unreadable map to a DTO MethodConfig methodConfig = new MethodConfig(formData); - // Initializing webClient to be used for http call - WebClient.Builder webClientBuilder = WebClient.builder(); - executionMethod.validateExecutionMethodRequest(methodConfig); - WebClient client = webClientBuilder + // Initializing webClient to be used for http call + WebClient client = WebClientUtils.builder() .exchangeStrategies(EXCHANGE_STRATEGIES) .build(); @@ -388,4 +387,4 @@ public class GoogleSheetsPlugin extends BasePlugin { templateMethod.replaceMethodConfigTemplate(formData, mappedColumns); } } -} \ No newline at end of file +} diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Aggregate.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Aggregate.java index ac5202e82c..940d5d67eb 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Aggregate.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Aggregate.java @@ -24,7 +24,6 @@ import java.util.Map; import static com.appsmith.external.helpers.PluginUtils.STRING_TYPE; import static com.appsmith.external.helpers.PluginUtils.setDataValueSafelyInFormData; import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData; -import static org.apache.commons.lang3.StringUtils.isBlank; import static com.external.plugins.constants.FieldName.AGGREGATE; import static com.external.plugins.constants.FieldName.AGGREGATE_LIMIT; import static com.external.plugins.constants.FieldName.AGGREGATE_PIPELINES; @@ -33,6 +32,7 @@ import static com.external.plugins.constants.FieldName.COLLECTION; import static com.external.plugins.constants.FieldName.COMMAND; import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION; import static com.external.plugins.utils.MongoPluginUtils.parseSafely; +import static org.apache.commons.lang3.StringUtils.isBlank; @Getter @Setter diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Count.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Count.java index a51ac7c40a..f82ff0e9b6 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Count.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Count.java @@ -22,9 +22,9 @@ import static com.external.plugins.constants.FieldName.COLLECTION; import static com.external.plugins.constants.FieldName.COMMAND; import static com.external.plugins.constants.FieldName.COUNT; import static com.external.plugins.constants.FieldName.COUNT_QUERY; -import static org.apache.commons.lang3.StringUtils.isBlank; import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION; import static com.external.plugins.utils.MongoPluginUtils.parseSafely; +import static org.apache.commons.lang3.StringUtils.isBlank; @Getter @Setter diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Distinct.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Distinct.java index 86fb989ea9..95d9f44d73 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Distinct.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Distinct.java @@ -23,9 +23,9 @@ import static com.external.plugins.constants.FieldName.COMMAND; import static com.external.plugins.constants.FieldName.DISTINCT; import static com.external.plugins.constants.FieldName.DISTINCT_KEY; import static com.external.plugins.constants.FieldName.DISTINCT_QUERY; -import static org.apache.commons.lang3.StringUtils.isBlank; import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION; import static com.external.plugins.utils.MongoPluginUtils.parseSafely; +import static org.apache.commons.lang3.StringUtils.isBlank; @Getter @Setter diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Find.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Find.java index cebea4a610..9eb30e5161 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Find.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Find.java @@ -27,8 +27,8 @@ import static com.external.plugins.constants.FieldName.FIND_QUERY; import static com.external.plugins.constants.FieldName.FIND_SKIP; import static com.external.plugins.constants.FieldName.FIND_SORT; import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION; -import static org.apache.commons.lang3.StringUtils.isBlank; import static com.external.plugins.utils.MongoPluginUtils.parseSafely; +import static org.apache.commons.lang3.StringUtils.isBlank; @Getter @Setter @@ -219,4 +219,4 @@ public class Find extends MongoCommand { return sb.toString(); } -} \ No newline at end of file +} diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Insert.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Insert.java index 212a628f6a..66bc5808b1 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Insert.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/commands/Insert.java @@ -31,8 +31,8 @@ import static com.external.plugins.constants.FieldName.COMMAND; import static com.external.plugins.constants.FieldName.INSERT; import static com.external.plugins.constants.FieldName.INSERT_DOCUMENT; import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION; -import static org.apache.commons.lang3.StringUtils.isBlank; import static com.external.plugins.utils.MongoPluginUtils.parseSafely; +import static org.apache.commons.lang3.StringUtils.isBlank; @Getter @Setter @@ -158,4 +158,4 @@ public class Insert extends MongoCommand { return sb.toString(); } -} \ No newline at end of file +} diff --git a/app/server/appsmith-plugins/mysqlPlugin/pom.xml b/app/server/appsmith-plugins/mysqlPlugin/pom.xml index 2860d33788..9fe613c5e7 100644 --- a/app/server/appsmith-plugins/mysqlPlugin/pom.xml +++ b/app/server/appsmith-plugins/mysqlPlugin/pom.xml @@ -73,12 +73,6 @@ - - io.netty - netty-all - provided - - mysql diff --git a/app/server/appsmith-plugins/rapidApiPlugin/src/main/java/com/external/plugins/RapidApiPlugin.java b/app/server/appsmith-plugins/rapidApiPlugin/src/main/java/com/external/plugins/RapidApiPlugin.java index ba1cb149d1..af270351f1 100644 --- a/app/server/appsmith-plugins/rapidApiPlugin/src/main/java/com/external/plugins/RapidApiPlugin.java +++ b/app/server/appsmith-plugins/rapidApiPlugin/src/main/java/com/external/plugins/RapidApiPlugin.java @@ -9,6 +9,7 @@ import com.appsmith.external.models.DatasourceTestResult; import com.appsmith.external.models.Property; import com.appsmith.external.plugins.BasePlugin; import com.appsmith.external.plugins.PluginExecutor; +import com.appsmith.util.WebClientUtils; import com.fasterxml.jackson.core.JsonProcessingException; import lombok.extern.slf4j.Slf4j; import org.bson.internal.Base64; @@ -76,7 +77,7 @@ public class RapidApiPlugin extends BasePlugin { "set.")); } - WebClient.Builder webClientBuilder = WebClient.builder(); + WebClient.Builder webClientBuilder = WebClientUtils.builder(); if (datasourceConfiguration.getHeaders() != null) { addHeadersToRequest(webClientBuilder, datasourceConfiguration.getHeaders()); diff --git a/app/server/appsmith-plugins/restApiPlugin/pom.xml b/app/server/appsmith-plugins/restApiPlugin/pom.xml index 99a7b20f75..a92ece7d51 100644 --- a/app/server/appsmith-plugins/restApiPlugin/pom.xml +++ b/app/server/appsmith-plugins/restApiPlugin/pom.xml @@ -43,26 +43,6 @@ provided - - org.springframework - spring-webflux - 5.3.20 - - - io.projectreactor - reactor-core - - - org.springframework - spring-core - - - org.springframework - spring-web - - - - com.fasterxml.jackson.core jackson-databind @@ -134,11 +114,6 @@ 5.3.20 test - - io.projectreactor.netty - reactor-netty-http - provided - com.squareup.okhttp3 mockwebserver diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java index 434367a361..30d3d0a322 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java @@ -7,6 +7,7 @@ import com.appsmith.external.models.AuthenticationResponse; import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.OAuth2; import com.appsmith.external.models.UpdatableConnection; +import com.appsmith.util.WebClientUtils; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -15,7 +16,6 @@ import org.bson.internal.Base64; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.reactive.function.BodyExtractors; @@ -109,8 +109,7 @@ public class OAuth2AuthorizationCode extends APIConnection implements UpdatableC final HttpClient securedHttpClient = this.getSecuredHttpClient(datasourceConfiguration); // Webclient - WebClient.Builder webClientBuilder = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(securedHttpClient)) + WebClient.Builder webClientBuilder = WebClientUtils.builder(securedHttpClient) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE) .exchangeStrategies(ExchangeStrategies .builder() @@ -244,4 +243,4 @@ public class OAuth2AuthorizationCode extends APIConnection implements UpdatableC return oAuth2; } -} \ No newline at end of file +} diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java index 2af68126a8..f8aa236296 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java @@ -7,6 +7,7 @@ import com.appsmith.external.models.AuthenticationResponse; import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.OAuth2; import com.appsmith.external.models.UpdatableConnection; +import com.appsmith.util.WebClientUtils; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -16,7 +17,6 @@ import org.bson.internal.Base64; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.reactive.function.BodyExtractors; @@ -88,8 +88,7 @@ public class OAuth2ClientCredentials extends APIConnection implements UpdatableC final HttpClient securedHttpClient = this.getSecuredHttpClient(datasourceConfiguration); // Webclient - final WebClient.Builder webClientBuilder = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(securedHttpClient)) + final WebClient.Builder webClientBuilder = WebClientUtils.builder(securedHttpClient) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE) .exchangeStrategies(ExchangeStrategies .builder() @@ -102,7 +101,6 @@ public class OAuth2ClientCredentials extends APIConnection implements UpdatableC webClientBuilder.defaultHeader("Authorization", authorizationHeader); } - // Webclient WebClient webClient = webClientBuilder.build(); @@ -223,4 +221,4 @@ public class OAuth2ClientCredentials extends APIConnection implements UpdatableC return oAuth2; } -} \ No newline at end of file +} diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java index 8b4a8de6d0..f70767cfd4 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java @@ -20,6 +20,7 @@ import com.appsmith.external.plugins.BasePlugin; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.external.plugins.SmartSubstitutionInterface; import com.appsmith.external.services.SharedConfig; +import com.appsmith.util.WebClientUtils; import com.external.connections.APIConnection; import com.external.connections.APIConnectionFactory; import com.external.constants.ResponseDataType; @@ -43,7 +44,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.InvalidMediaTypeException; import org.springframework.http.MediaType; import org.springframework.http.client.reactive.ClientHttpRequest; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.util.CollectionUtils; import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.client.ClientResponse; @@ -299,12 +299,7 @@ public class RestApiPlugin extends BasePlugin { .secure(SSLHelper.sslCheckForHttpClient(datasourceConfiguration)) .compress(true); - if ("true".equals(System.getProperty("java.net.useSystemProxies")) - && (!System.getProperty("http.proxyHost", "").isEmpty() || !System.getProperty("https.proxyHost", "").isEmpty())) { - httpClient = httpClient.proxyWithSystemProperties(); - } - - WebClient.Builder webClientBuilder = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)); + WebClient.Builder webClientBuilder = WebClientUtils.builder(httpClient); // Adding headers from datasource if (datasourceConfiguration.getHeaders() != null) { diff --git a/app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java b/app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java index c9a74a0955..d335fac0ed 100644 --- a/app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java +++ b/app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java @@ -12,6 +12,7 @@ import com.appsmith.external.plugins.BasePlugin; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.external.plugins.SmartSubstitutionInterface; import com.appsmith.external.services.SharedConfig; +import com.appsmith.util.WebClientUtils; import com.external.helpers.RequestCaptureFilter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; @@ -105,7 +106,7 @@ public class SaasPlugin extends BasePlugin { // Initializing webClient to be used for http call - WebClient.Builder webClientBuilder = WebClient.builder(); + WebClient.Builder webClientBuilder = WebClientUtils.builder(); webClientBuilder.defaultHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE); final RequestCaptureFilter requestCaptureFilter = new RequestCaptureFilter(objectMapper); webClientBuilder.filter(requestCaptureFilter); @@ -216,4 +217,4 @@ public class SaasPlugin extends BasePlugin { return Mono.error(new AppsmithPluginException(AppsmithPluginError.UNSUPPORTED_PLUGIN_OPERATION)); } } -} \ No newline at end of file +} diff --git a/app/server/appsmith-server/pom.xml b/app/server/appsmith-server/pom.xml index f04e90603f..6c814bfccf 100644 --- a/app/server/appsmith-server/pom.xml +++ b/app/server/appsmith-server/pom.xml @@ -64,6 +64,7 @@ org.springframework.boot spring-boot-starter-webflux + 2.7.0 org.springframework.boot diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java index 03d43576e4..ccfdfdf598 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java @@ -6,6 +6,7 @@ import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.services.ConfigService; +import com.appsmith.util.WebClientUtils; import io.sentry.Sentry; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -15,7 +16,6 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import java.util.Map; @@ -56,7 +56,7 @@ public class InstanceConfig implements ApplicationListener WebClient + .flatMap(instanceId -> WebClientUtils .create(baseUrl + "/api/v1/installations") .post() .body(BodyInserters.fromValue(Map.of("key", instanceId))) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitCloudServicesUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitCloudServicesUtils.java index 6def85fefb..e3a282a48c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitCloudServicesUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitCloudServicesUtils.java @@ -7,11 +7,11 @@ import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.services.ConfigService; +import com.appsmith.util.WebClientUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.core.ParameterizedTypeReference; import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import java.time.Instant; @@ -42,7 +42,7 @@ public class GitCloudServicesUtils { return Mono.just(gitLimitCache.get(key).getRepoLimit()); } // Call the cloud service API - return WebClient + return WebClientUtils .create(baseUrl + "/api/v1/git/limit/" + key) .get() .exchange() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java index 33bd3c82c2..c3e49df269 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java @@ -1,18 +1,14 @@ package com.appsmith.server.helpers; -import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; +import com.appsmith.util.WebClientUtils; import org.eclipse.jgit.util.StringUtils; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClientRequest; import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; import java.time.Duration; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -67,7 +63,7 @@ public class GitUtils { * @throws IOException exception thrown during openConnection */ public static Mono isRepoPrivate(String remoteHttpsUrl) { - return WebClient + return WebClientUtils .create(remoteHttpsUrl) .get() .httpRequest(httpRequest -> { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java index c6e1e9202a..3ab5c2c248 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java @@ -1,6 +1,6 @@ package com.appsmith.server.helpers; -import org.springframework.web.reactive.function.client.WebClient; +import com.appsmith.util.WebClientUtils; import reactor.core.publisher.Mono; import java.net.URI; @@ -24,7 +24,7 @@ public class NetworkUtils { return Mono.just(cachedAddress); } - return WebClient + return WebClientUtils .create() .get() .uri(GET_IP_URI) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationTemplateServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationTemplateServiceCEImpl.java index 9899d71016..6a93fc9823 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationTemplateServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationTemplateServiceCEImpl.java @@ -14,6 +14,7 @@ import com.appsmith.server.services.AnalyticsService; import com.appsmith.server.services.UserDataService; import com.appsmith.server.solutions.ImportExportApplicationService; import com.appsmith.server.solutions.ReleaseNotesService; +import com.appsmith.util.WebClientUtils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; @@ -67,7 +68,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ String apiUrl = uriComponents.toUriString(); - return WebClient + return WebClientUtils .create(apiUrl) .get() .exchangeToFlux(clientResponse -> { @@ -95,7 +96,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ // uriComponents will build url in format: version=version&id=id1&id=id2&id=id3 UriComponents uriComponents = uriComponentsBuilder.build(); - return WebClient + return WebClientUtils .create(baseUrl + "/api/v1/app-templates?" + uriComponents.getQuery()) .get() .exchangeToFlux(clientResponse -> { @@ -132,7 +133,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ public Mono getTemplateDetails(String templateId) { final String baseUrl = cloudServicesConfig.getBaseUrl(); - return WebClient + return WebClientUtils .create(baseUrl + "/api/v1/app-templates/" + templateId) .get() .exchangeToMono(clientResponse -> { @@ -157,7 +158,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ .codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(size)) .build(); - WebClient webClient = WebClient.builder() + WebClient webClient = WebClientUtils.builder() .uriBuilderFactory(new NoEncodingUriBuilderFactory(templateUrl)) .exchangeStrategies(strategies) .build(); @@ -213,7 +214,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ public Mono getFilters() { final String baseUrl = cloudServicesConfig.getBaseUrl(); - return WebClient + return WebClientUtils .create(baseUrl + "/api/v1/app-templates/filters") .get() .exchangeToMono(clientResponse -> { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/MockDataServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/MockDataServiceCEImpl.java index 200079ad87..9f1e553c0a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/MockDataServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/MockDataServiceCEImpl.java @@ -1,5 +1,6 @@ package com.appsmith.server.services.ce; +import com.appsmith.external.constants.AnalyticsEvents; import com.appsmith.external.models.Connection; import com.appsmith.external.models.DBAuth; import com.appsmith.external.models.Datasource; @@ -8,7 +9,6 @@ import com.appsmith.external.models.Endpoint; import com.appsmith.external.models.Property; import com.appsmith.external.models.SSLDetails; import com.appsmith.server.configurations.CloudServicesConfig; -import com.appsmith.external.constants.AnalyticsEvents; import com.appsmith.server.domains.User; import com.appsmith.server.dtos.MockDataCredentials; import com.appsmith.server.dtos.MockDataDTO; @@ -19,12 +19,12 @@ import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.services.AnalyticsService; import com.appsmith.server.services.DatasourceService; import com.appsmith.server.services.SessionUserService; +import com.appsmith.util.WebClientUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.dao.DuplicateKeyException; import org.springframework.util.StringUtils; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import java.time.Instant; @@ -69,7 +69,7 @@ public class MockDataServiceCEImpl implements MockDataServiceCE { return Mono.justOrEmpty(mockData); } - return WebClient + return WebClientUtils .create(baseUrl + "/api/v1/mocks") .get() .exchange() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java index 75595bf35e..13f42e287e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java @@ -2,13 +2,13 @@ package com.appsmith.server.services.ce; import com.appsmith.external.models.Datasource; import com.appsmith.server.constants.FieldName; -import com.appsmith.server.domains.Workspace; -import com.appsmith.server.domains.WorkspacePlugin; import com.appsmith.server.domains.Plugin; import com.appsmith.server.domains.PluginType; +import com.appsmith.server.domains.Workspace; +import com.appsmith.server.domains.WorkspacePlugin; import com.appsmith.server.dtos.InstallPluginRedisDTO; -import com.appsmith.server.dtos.WorkspacePluginStatus; import com.appsmith.server.dtos.PluginWorkspaceDTO; +import com.appsmith.server.dtos.WorkspacePluginStatus; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.repositories.PluginRepository; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java index 9e1a2a1da0..96135adb8f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java @@ -26,12 +26,12 @@ import com.appsmith.server.services.ConfigService; import com.appsmith.server.services.DatasourceService; import com.appsmith.server.services.NewPageService; import com.appsmith.server.services.PluginService; +import com.appsmith.util.WebClientUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.bson.internal.Base64; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -175,8 +175,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { httpClient.secure(SSLHelper.sslCheckForHttpClient(datasource.getDatasourceConfiguration())); } - WebClient.Builder builder = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(httpClient)) + WebClient.Builder builder = WebClientUtils.builder(httpClient) .baseUrl(oAuth2.getAccessTokenUrl()); MultiValueMap map = new LinkedMultiValueMap<>(); @@ -346,9 +345,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { return integrationDTO; })) .flatMap(integrationDTO -> { - WebClient.Builder builder = WebClient.builder(); - builder.baseUrl(cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/appsmith"); - return builder.build() + return WebClientUtils.create(cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/appsmith") .method(HttpMethod.POST) .body(BodyInserters.fromValue(integrationDTO)) .exchange() @@ -395,7 +392,6 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE, datasourceId))) .flatMap(this::validateRequiredFieldsForGenericOAuth2) .flatMap(datasource -> { - WebClient.Builder builder = WebClient.builder(); UriComponentsBuilder uriBuilder = UriComponentsBuilder.newInstance(); try { uriBuilder.uri(new URI(cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/token")) @@ -403,7 +399,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { } catch (URISyntaxException e) { log.debug("Error while parsing access token URL.", e); } - return builder.build() + return WebClientUtils.create() .method(HttpMethod.POST) .uri(uriBuilder.build(true).toUri()) .exchange() @@ -463,11 +459,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { integrationDTO.setPluginName(plugin.getPluginName()); integrationDTO.setPluginVersion(plugin.getVersion()); - WebClient.Builder builder = WebClient - .builder() - .baseUrl(cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/refresh"); - - return builder.build() + return WebClientUtils.create(cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/refresh") .method(HttpMethod.POST) .body(BodyInserters.fromValue(integrationDTO)) .exchange() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PingScheduledTaskCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PingScheduledTaskCEImpl.java index 3c4b020f35..8cba129b02 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PingScheduledTaskCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PingScheduledTaskCEImpl.java @@ -7,9 +7,10 @@ import com.appsmith.server.repositories.ApplicationRepository; import com.appsmith.server.repositories.DatasourceRepository; import com.appsmith.server.repositories.NewActionRepository; import com.appsmith.server.repositories.NewPageRepository; -import com.appsmith.server.repositories.WorkspaceRepository; import com.appsmith.server.repositories.UserRepository; +import com.appsmith.server.repositories.WorkspaceRepository; import com.appsmith.server.services.ConfigService; +import com.appsmith.util.WebClientUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -17,7 +18,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.http.MediaType; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -82,7 +82,7 @@ public class PingScheduledTaskCEImpl implements PingScheduledTaskCE { return Mono.empty(); } - return WebClient + return WebClientUtils .create("https://api.segment.io") .post() .uri("/v1/track") @@ -123,7 +123,7 @@ public class PingScheduledTaskCEImpl implements PingScheduledTaskCE { ) .flatMap(statsData -> { final String ipAddress = statsData.getT2(); - return WebClient + return WebClientUtils .create("https://api.segment.io") .post() .uri("/v1/track") diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java index fdc6f9cdb6..1c242cd051 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java @@ -1,11 +1,12 @@ package com.appsmith.server.solutions.ce; import com.appsmith.server.configurations.CloudServicesConfig; -import com.appsmith.server.domains.Workspace; import com.appsmith.server.domains.Plugin; +import com.appsmith.server.domains.Workspace; import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.services.ConfigService; import com.appsmith.server.services.PluginService; +import com.appsmith.util.WebClientUtils; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -14,7 +15,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.core.ParameterizedTypeReference; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.util.StringUtils; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -104,7 +104,7 @@ public class PluginScheduledTaskCEImpl implements PluginScheduledTaskCE { } return configService.getInstanceId() - .flatMap(instanceId -> WebClient + .flatMap(instanceId -> WebClientUtils .create( baseUrl + "/api/v1/plugins?instanceId=" + instanceId + "&lastUpdatedAt=" + lastUpdatedAt) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ReleaseNotesServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ReleaseNotesServiceCEImpl.java index 4c561d2608..d93b83da10 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ReleaseNotesServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ReleaseNotesServiceCEImpl.java @@ -7,6 +7,7 @@ import com.appsmith.server.configurations.SegmentConfig; import com.appsmith.server.dtos.ReleaseNode; import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.services.ConfigService; +import com.appsmith.util.WebClientUtils; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -14,7 +15,6 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -58,7 +58,7 @@ public class ReleaseNotesServiceCEImpl implements ReleaseNotesServiceCE { } return configService.getInstanceId() - .flatMap(instanceId -> WebClient + .flatMap(instanceId -> WebClientUtils .create( baseUrl + "/api/v1/releases?instanceId=" + instanceId + // isCloudHosted should be true only for our cloud instance, diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceTriggerSolutionTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceTriggerSolutionTest.java index 17c1088aed..9d83007585 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceTriggerSolutionTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceTriggerSolutionTest.java @@ -7,14 +7,14 @@ import com.appsmith.external.models.DatasourceStructure; import com.appsmith.external.models.TriggerRequestDTO; import com.appsmith.external.models.TriggerResultDTO; import com.appsmith.external.plugins.PluginExecutor; -import com.appsmith.server.domains.Workspace; import com.appsmith.server.domains.Plugin; +import com.appsmith.server.domains.Workspace; import com.appsmith.server.helpers.MockPluginExecutor; import com.appsmith.server.helpers.PluginExecutorHelper; import com.appsmith.server.services.DatasourceService; -import com.appsmith.server.services.WorkspaceService; import com.appsmith.server.services.PluginService; import com.appsmith.server.services.UserService; +import com.appsmith.server.services.WorkspaceService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/app/server/reactive-caching/pom.xml b/app/server/reactive-caching/pom.xml index b3ad052fb5..803a675863 100644 --- a/app/server/reactive-caching/pom.xml +++ b/app/server/reactive-caching/pom.xml @@ -45,6 +45,7 @@ org.springframework.boot spring-boot-starter-webflux + 2.7.0 @@ -70,7 +71,7 @@ junit-jupiter-api test - + org.junit.jupiter junit-jupiter-engine diff --git a/deploy/docker/scripts/run-java.sh b/deploy/docker/scripts/run-java.sh index bd9c7cbe9d..b92a0602ec 100755 --- a/deploy/docker/scripts/run-java.sh +++ b/deploy/docker/scripts/run-java.sh @@ -8,12 +8,12 @@ set -o noglob declare -a proxy_args proxy_configured=0 -if [[ ${HTTP_PROXY-} =~ ^http://(.*):(.*)$ && ${BASH_REMATCH[2]} != 0 ]]; then +if [[ ${HTTP_PROXY-} =~ ^http://(.*):([[:digit:]]*)/?$ && ${BASH_REMATCH[2]} != 0 ]]; then proxy_args+=(-Dhttp.proxyHost="${BASH_REMATCH[1]}" -Dhttp.proxyPort="${BASH_REMATCH[2]}") proxy_configured=1 fi -if [[ ${HTTPS_PROXY-} =~ ^https?://(.*):(.*)$ && ${BASH_REMATCH[2]} != 0 ]]; then +if [[ ${HTTPS_PROXY-} =~ ^https?://(.*):([[:digit:]]*)/?$ && ${BASH_REMATCH[2]} != 0 ]]; then proxy_args+=(-Dhttps.proxyHost="${BASH_REMATCH[1]}" -Dhttps.proxyPort="${BASH_REMATCH[2]}") proxy_configured=1 fi