Skip to content

Fix return type of substring method#1504

Merged
kstich merged 3 commits intosmithy-lang:mainfrom
skmcgrail:substring-return-type
Dec 1, 2022
Merged

Fix return type of substring method#1504
kstich merged 3 commits intosmithy-lang:mainfrom
skmcgrail:substring-return-type

Conversation

@rcoh
Copy link
Copy Markdown
Contributor

@rcoh rcoh commented Nov 18, 2022

Description of changes: The type signature of the substring endpoint method was incorrect—substring will return None when the resulting input string is shorter than the substring operation requires.

This could lead to invalid rules being accepted by the rules engine.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rcoh rcoh requested a review from a team as a code owner November 18, 2022 17:48
@rcoh rcoh force-pushed the substring-return-type branch from 7fcd3a8 to 6402cde Compare November 28, 2022 19:43
@rcoh rcoh force-pushed the substring-return-type branch from 6402cde to be4661b Compare November 28, 2022 19:44
public class RulesetTestUtil {
public static EndpointRuleSet loadRuleSet(String resourceId) {
InputStream is = RulesetTestUtil.class.getClassLoader().getResourceAsStream(resourceId);
assert is != null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can use the try-with-resources (try (InputStream is...) {) pattern to not need this assertion and also safely close the stream.

@kstich kstich merged commit 10fd0d1 into smithy-lang:main Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants