Skip to content

Commit 6e1c381

Browse files
committed
Moved simple methods to be whitelist-based. Messages are logged when a potentially-simple method is encountered that hasn't been whitelisted or blacklisted.
1 parent 4f4ab96 commit 6e1c381

File tree

141 files changed

+2132
-1123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2132
-1123
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"type": "bugfix",
4+
"description": "Removed broken client methods: `BackupClient#getSupportedResourceTypes()` and `PinpointSmsVoiceClient.listConfigurationSets()`."
5+
}

codegen/src/main/java/software/amazon/awssdk/codegen/IntermediateModelBuilder.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import software.amazon.awssdk.codegen.model.service.ServiceModel;
4646
import software.amazon.awssdk.codegen.naming.DefaultNamingStrategy;
4747
import software.amazon.awssdk.codegen.naming.NamingStrategy;
48+
import software.amazon.awssdk.utils.CollectionUtils;
4849

4950
/**
5051
* Builds an intermediate model to be used by the templates from the service model and
@@ -247,24 +248,24 @@ private void linkAuthorizationToRequestShapeForAwsProtocol(AuthType authType, Sh
247248
}
248249

249250
private void setSimpleMethods(IntermediateModel model) {
250-
model.getOperations().entrySet().forEach(m -> {
251-
252-
ShapeModel inputShape = m.getValue().getInputShape();
253-
String methodName = m.getValue().getMethodName();
254-
CustomizationConfig config = model.getCustomizationConfig();
255-
256-
if (inputShape.getRequired() == null
257-
&& !config.getBlacklistedSimpleMethods().contains(methodName)
258-
&& !(config.getBlacklistedSimpleMethods().size() == 1 && config.getBlacklistedSimpleMethods().get(0).equals("*"))
259-
&& !m.getValue().hasStreamingInput()
260-
&& !m.getValue().hasStreamingOutput()) {
261-
262-
if (!methodName.matches(Constant.APPROVED_SIMPLE_METHOD_VERBS) &&
263-
!config.getVerifiedSimpleMethods().contains(methodName)) {
264-
// TODO: How do we prevent these from being missed before services launch?
265-
log.warn("Simple method encountered that is not approved or blacklisted: " + methodName);
266-
} else {
267-
inputShape.setSimpleMethod(true);
251+
CustomizationConfig config = model.getCustomizationConfig();
252+
model.getOperations().values().forEach(operation -> {
253+
ShapeModel inputShape = operation.getInputShape();
254+
String methodName = operation.getMethodName();
255+
256+
if (config.getVerifiedSimpleMethods().contains(methodName)) {
257+
inputShape.setSimpleMethod(true);
258+
} else {
259+
inputShape.setSimpleMethod(false);
260+
261+
boolean methodIsNotBlacklisted = !config.getBlacklistedSimpleMethods().contains(methodName) ||
262+
config.getBlacklistedSimpleMethods().stream().noneMatch(m -> m.equals("*"));
263+
boolean methodHasNoRequiredMembers = !CollectionUtils.isNullOrEmpty(inputShape.getRequired());
264+
boolean methodIsNotStreaming = !operation.isStreaming();
265+
boolean methodHasSimpleMethodVerb = methodName.matches(Constant.APPROVED_SIMPLE_METHOD_VERBS);
266+
267+
if (methodIsNotBlacklisted && methodHasNoRequiredMembers && methodIsNotStreaming && methodHasSimpleMethodVerb) {
268+
log.warn("A potential simple method exists that isn't whitelisted or blacklisted: " + methodName);
268269
}
269270
}
270271
});

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/IntermediateModel.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
package software.amazon.awssdk.codegen.model.intermediate;
1717

18-
import static software.amazon.awssdk.codegen.internal.Constant.APPROVED_SIMPLE_METHOD_VERBS;
19-
2018
import com.fasterxml.jackson.annotation.JsonCreator;
2119
import com.fasterxml.jackson.annotation.JsonIgnore;
2220
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -37,12 +35,6 @@
3735
import software.amazon.awssdk.utils.IoUtils;
3836

3937
public final class IntermediateModel {
40-
41-
/**
42-
* This is used for all service clients unless overridden in the Customizations file.
43-
*/
44-
private static final String DEFAULT_CLIENT_CONFIG_FACTORY = "LegacyClientConfigurationFactory";
45-
4638
private final Metadata metadata;
4739

4840
private final Map<String, OperationModel> operations;
@@ -203,8 +195,6 @@ private String getResponseMetadataClassName() {
203195
public List<OperationModel> simpleMethodsRequiringTesting() {
204196
return getOperations().values().stream()
205197
.filter(v -> v.getInputShape().isSimpleMethod())
206-
.filter(v -> !getCustomizationConfig().getVerifiedSimpleMethods().contains(v.getMethodName()))
207-
.filter(v -> v.getMethodName().matches(APPROVED_SIMPLE_METHOD_VERBS))
208198
.collect(Collectors.toList());
209199
}
210200

0 commit comments

Comments
 (0)