Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: More warning and deprecated API fixes #33141

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -81,21 +80,11 @@ public Builder() {
basePackagesToScan = new ArrayList<>();
}

public Builder withBasePackage(String basePackage) {
basePackagesToScan.add(basePackage);
return this;
}

public Builder withBasePackages(String[] basePackages) {
basePackagesToScan.addAll(Arrays.asList(basePackages));
return this;
}

public Builder withBasePackages(Collection<? extends String> basePackages) {
basePackagesToScan.addAll(basePackages);
return this;
}

public DocumentTypeMapper build() {
return new DocumentTypeMapper(basePackagesToScan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
@Slf4j
public class DataTypeStringUtils {

private static String regexForQuestionMark = "\\?";

private static Pattern questionPattern = Pattern.compile(regexForQuestionMark);

public static Pattern placeholderPattern = Pattern.compile(APPSMITH_SUBSTITUTION_PLACEHOLDER);

private static ObjectMapper objectMapper = SerializationUtils.getObjectMapperWithSourceInLocationEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.io.IOException;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -67,12 +67,12 @@ public Type getType() {
* (2) '"around"'
* (3) "the"
* (4) 'sun'
* - ref: https://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks
* <a href="https://stackoverflow.com/q/171480">Reference</a>.
*/
public static String MATCH_QUOTED_WORDS_REGEX = "([\\\"'])(?:(?=(\\\\?))\\2.)*?\\1";

public static List<String> getColumnsListForJdbcPlugin(ResultSetMetaData metaData) throws SQLException {
List<String> columnsList = IntStream.range(1, metaData.getColumnCount() + 1) // JDBC column indexes start from 1
return IntStream.range(1, metaData.getColumnCount() + 1) // JDBC column indexes start from 1
.mapToObj(i -> {
try {
return metaData.getColumnName(i);
Expand All @@ -84,8 +84,6 @@ public static List<String> getColumnsListForJdbcPlugin(ResultSetMetaData metaDat
}
})
.collect(Collectors.toList());

return columnsList;
}

public static List<String> getIdenticalColumns(List<String> columnNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.appsmith.external.models.AuthenticationDTO;
import com.appsmith.external.models.OAuth2;
import org.springframework.util.StringUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,23 @@ public class HeaderUtils {
public static final String IS_SEND_SESSION_ENABLED_KEY = "isSendSessionEnabled";
public static final String SESSION_SIGNATURE_KEY_KEY = "sessionSignatureKey";

/**
* If encodeParamsToggle is null, then assume it to be true because params are supposed to be
* encoded by default, unless explicitly prohibited by the user.
*/
public boolean isEncodeParamsToggleEnabled(ActionConfiguration actionConfiguration) {
/**
* If encodeParamsToggle is null, then assume it to be true because params are supposed to be
* encoded by default, unless explicitly prohibited by the user.
*/
if (actionConfiguration.getEncodeParamsToggle() != null
&& actionConfiguration.getEncodeParamsToggle() == false) {
return false;
}

return true;
return !Boolean.FALSE.equals(actionConfiguration.getEncodeParamsToggle());
}

/**
* We only check for key being empty since an empty value is still a valid header.
* <a href="https://stackoverflow.com/questions/12130910/how-to-interpret-empty-http-accept-header">Reference</a>.
*/
public void removeEmptyHeaders(ActionConfiguration actionConfiguration) {
/**
* We only check for key being empty since an empty value is still a valid header.
* Ref: https://stackoverflow.com/questions/12130910/how-to-interpret-empty-http-accept-header
*/
if (actionConfiguration.getHeaders() != null
&& !actionConfiguration.getHeaders().isEmpty()) {
List<Property> headerList = actionConfiguration.getHeaders().stream()
.filter(header -> !org.springframework.util.StringUtils.isEmpty(header.getKey()))
.filter(header -> !StringUtils.isEmpty(header.getKey()))
.collect(Collectors.toList());
actionConfiguration.setHeaders(headerList);
}
Expand Down Expand Up @@ -142,18 +137,15 @@ public void setHeaderFromAutoGeneratedHeaders(ActionConfiguration actionConfigur
}

Set<String> userAddedHeaderKeys = actionConfiguration.getHeaders().stream()
.filter(header -> !StringUtils.isEmpty(header.getKey()))
.map(Property::getKey)
.filter(key -> !StringUtils.isEmpty(key))
.map(String::toLowerCase) // Header keys are case-insensitive
.collect(Collectors.toSet());

actionConfiguration.getAutoGeneratedHeaders().stream()
.filter(header -> !StringUtils.isEmpty(header.getKey()))
.forEach(header -> {
/**
* Header keys are case insensitive:
* https://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
*/
// Header keys are case-insensitive.
if (!userAddedHeaderKeys.contains(header.getKey().toLowerCase())) {
actionConfiguration.getHeaders().add(header);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;

@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
@FieldNameConstants
public class ActionDTO extends ActionCE_DTO {
public static class Fields extends ActionCE_DTO.Fields {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import com.appsmith.external.models.ce.DefaultResourcesCE;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;

/**
* This class will be used for connecting resources across branches for git connected application
* e.g. Page1 in branch1 will have the same defaultResources.pageId as of Page1 of branch2
*/
@EqualsAndHashCode(callSuper = true)
@Data
@FieldNameConstants
public class DefaultResources extends DefaultResourcesCE {
public static class Fields extends DefaultResourcesCE.Fields {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.data.annotation.Transient;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;

import java.time.Instant;
Expand Down Expand Up @@ -103,7 +103,7 @@ public void setScopeString(String scopeString) {
this.scopeString = scopeString;
if (scopeString != null && !scopeString.isBlank()) {
this.scope = Arrays.stream(scopeString.split(","))
.filter(x -> !StringUtils.isEmpty(x))
.filter(StringUtils::isNotEmpty)
.map(String::trim)
.collect(Collectors.toSet());
}
Expand Down