Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
5 changes: 2 additions & 3 deletions ask-sdk-apache-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ private HttpUriRequest generateRequest(final ApiClientRequest request) {
}
}

if (lowLevelRequest instanceof HttpEntityEnclosingRequestBase && request.getBody() != null) {
if (lowLevelRequest instanceof HttpEntityEnclosingRequestBase base && request.getBody() != null) {
StringEntity entity = new StringEntity(request.getBody(), ContentType.APPLICATION_JSON);
((HttpEntityEnclosingRequestBase) lowLevelRequest).setEntity(entity);
base.setEntity(entity);
}

return lowLevelRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void api_client_response_contains_expected_data() throws Exception {
assertEquals(response.getBody(), TEST_PAYLOAD);
List<Pair<String, String>> headers = response.getHeaders();
assertEquals(headers.size(), 1);
Pair<String, String> header = headers.get(0);
Pair<String, String> header = headers.getFirst();
assertEquals(header.getName(), "foo");
assertEquals(header.getValue(), "bar");
}
Expand Down
5 changes: 2 additions & 3 deletions ask-sdk-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public SlotValue unwrap() {
* or a singleton list consisting of the current wrapper.
*/
public List<SlotValueWrapper> values() {
if (slotValue instanceof ListSlotValue) {
return ((ListSlotValue)slotValue).getValues().stream()
if (slotValue instanceof ListSlotValue value) {
return value.getValues().stream()
.map(SlotValueWrapper::createFrom)
.collect(Collectors.toList());
}
Expand All @@ -81,7 +81,7 @@ public List<SlotValueWrapper> values() {
* @return underlying slot type as {@link SimpleSlotValue} or {@link Optional} empty.
*/
public Optional<SimpleSlotValue> asSimple() {
return slotValue instanceof SimpleSlotValue ? Optional.of((SimpleSlotValue) slotValue) : Optional.empty();
return slotValue instanceof SimpleSlotValue ssv ? Optional.of(ssv) : Optional.empty();
}

/**
Expand All @@ -91,7 +91,7 @@ public Optional<SimpleSlotValue> asSimple() {
* @return underlying slot type as {@link ListSlotValue} or {@link Optional} empty.
*/
public Optional<ListSlotValue> asList() {
return slotValue instanceof ListSlotValue ? Optional.of((ListSlotValue) slotValue) : Optional.empty();
return slotValue instanceof ListSlotValue lsv ? Optional.of(lsv) : Optional.empty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private int getEnumerationSize(final HandlerInput handlerInput) {
if (matcher.matches()) {
return NON_NULL_LOCALE_ENUMERATION_SIZE;
}
String message = String.format("Invalid locale: %s", locale);
String message = "Invalid locale: %s".formatted(locale);
LOGGER.error(message);
throw new IllegalArgumentException(message);
}
Expand Down
2 changes: 1 addition & 1 deletion ask-sdk-core/src/com/amazon/ask/util/UserAgentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static String getUserAgent(final String customUserAgent) {
* @return customUserAgent.
*/
static String internalGetUserAgent(final Properties systemProperties, final String customUserAgent) {
String coreUserAgent = String.format("ask-java/%s Java/%s", SdkConstants.SDK_VERSION, getJavaVersion(systemProperties));
String coreUserAgent = "ask-java/%s Java/%s".formatted(SdkConstants.SDK_VERSION, getJavaVersion(systemProperties));
return coreUserAgent + (customUserAgent != null ? " " + customUserAgent : "");
}

Expand Down
8 changes: 4 additions & 4 deletions ask-sdk-core/tst/com/amazon/ask/builder/SkillBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void request_mapper_configured_with_handler() {
when(mockRequestHandler.canHandle(any())).thenReturn(true);
builder.addRequestHandler(mockRequestHandler);
SkillConfiguration configuration = builder.getConfigBuilder().build();
GenericRequestMapper<HandlerInput, Optional<Response>> mapper = configuration.getRequestMappers().get(0);
GenericRequestMapper<HandlerInput, Optional<Response>> mapper = configuration.getRequestMappers().getFirst();
assertTrue(mapper instanceof GenericRequestMapper);
assertEquals(mockRequestHandler, mapper.getRequestHandlerChain(getInputForIntent("FooIntent")).get().getRequestHandler());
}
Expand All @@ -74,7 +74,7 @@ public void request_interceptor_used() {
builder.addRequestHandler(mockRequestHandler);
builder.addRequestInterceptor(requestInterceptor);
SkillConfiguration configuration = builder.getConfigBuilder().build();
assertEquals(configuration.getRequestInterceptors().get(0), requestInterceptor);
assertEquals(configuration.getRequestInterceptors().getFirst(), requestInterceptor);
}

@Test
Expand All @@ -83,7 +83,7 @@ public void response_interceptor_used() {
builder.addRequestHandler(mockRequestHandler);
builder.addResponseInterceptor(responseInterceptor);
GenericSkillConfiguration configuration = builder.getConfigBuilder().build();
assertEquals(configuration.getResponseInterceptors().get(0), responseInterceptor);
assertEquals(configuration.getResponseInterceptors().getFirst(), responseInterceptor);
}

@Test
Expand All @@ -104,7 +104,7 @@ public void default_handler_adapter_used() {
builder.addRequestHandler(mockRequestHandler);
SkillConfiguration configuration = builder.getConfigBuilder().build();
assertEquals(1, configuration.getHandlerAdapters().size());
assertTrue(configuration.getHandlerAdapters().get(0) instanceof BaseHandlerAdapter);
assertTrue(configuration.getHandlerAdapters().getFirst() instanceof BaseHandlerAdapter);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void values_returns_singleton_list_for_non_list_type() {
SlotValueWrapper wrapper = SlotValueWrapper.createFrom(testSimpleSlotValue);
List<SlotValueWrapper> values = wrapper.values();
assertEquals(values.size(), 1);
SlotValueWrapper listWrapper = values.get(0);
SlotValueWrapper listWrapper = values.getFirst();
assertEquals(listWrapper.unwrap(), testSimpleSlotValue);
}

Expand Down
6 changes: 3 additions & 3 deletions ask-sdk-core/tst/com/amazon/ask/util/UserAgentUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void userAgentGeneratedWithExpectedSdkAndJvmVersion() {
String version = "1.8.0_151";
Properties props = mock(Properties.class);
when(props.getProperty("java.version")).thenReturn(version);
assertEquals(UserAgentUtils.internalGetUserAgent(props, null), String.format("ask-java/%s Java/%s", SdkConstants.SDK_VERSION, version));
assertEquals(UserAgentUtils.internalGetUserAgent(props, null), "ask-java/%s Java/%s".formatted(SdkConstants.SDK_VERSION, version));
}

@Test
Expand All @@ -37,12 +37,12 @@ public void customUserAgentAppendedToEnd() {
String customUserAgent = "foo/bar/baz";
Properties props = mock(Properties.class);
when(props.getProperty("java.version")).thenReturn(version);
assertEquals(UserAgentUtils.internalGetUserAgent(props, customUserAgent), String.format("ask-java/%s Java/%s foo/bar/baz", SdkConstants.SDK_VERSION, version));
assertEquals(UserAgentUtils.internalGetUserAgent(props, customUserAgent), "ask-java/%s Java/%s foo/bar/baz".formatted(SdkConstants.SDK_VERSION, version));
}

@Test
public void nullJvmPropertiesReturnsUnknownJvmVersion() {
assertEquals(UserAgentUtils.internalGetUserAgent(null, null), String.format("ask-java/%s Java/UNKNOWN", SdkConstants.SDK_VERSION));
assertEquals(UserAgentUtils.internalGetUserAgent(null, null), "ask-java/%s Java/UNKNOWN".formatted(SdkConstants.SDK_VERSION));
}

}
5 changes: 2 additions & 3 deletions ask-sdk-dynamodb-persistence-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public Optional<Map<String, Object>> getAttributes(final RequestEnvelope envelop
try {
result = dynamoDb.getItem(request).getItem();
} catch (ResourceNotFoundException e) {
throw new PersistenceException(String.format("Table %s does not exist or is in the process of being created", tableName), e);
throw new PersistenceException("Table %s does not exist or is in the process of being created".formatted(tableName), e);
} catch (AmazonDynamoDBException e) {
throw new PersistenceException("Failed to retrieve attributes from DynamoDB", e);
}
Expand All @@ -170,7 +170,7 @@ public void saveAttributes(final RequestEnvelope envelope, final Map<String, Obj
try {
dynamoDb.putItem(request);
} catch (ResourceNotFoundException e) {
throw new PersistenceException(String.format("Table %s does not exist or is in the process of being created", tableName), e);
throw new PersistenceException("Table %s does not exist or is in the process of being created".formatted(tableName), e);
} catch (AmazonDynamoDBException e) {
throw new PersistenceException("Failed to save attributes to DynamoDB", e);
}
Expand All @@ -190,7 +190,7 @@ public void deleteAttributes(final RequestEnvelope envelope) throws PersistenceE
try {
dynamoDb.deleteItem(deleteItemRequest);
} catch (ResourceNotFoundException e) {
throw new PersistenceException(String.format("Table %s does not exist", tableName), e);
throw new PersistenceException("Table %s does not exist".formatted(tableName), e);
} catch (AmazonDynamoDBException e) {
throw new PersistenceException("Failed to delete attributes from DynamoDB", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ public void create_table_called_on_instantiation_when_enabled() {

List<AttributeDefinition> attributeDefinitions = createTableRequestCaptor.getValue().getAttributeDefinitions();
assertEquals(1, attributeDefinitions.size());
AttributeDefinition attributeDefinition = attributeDefinitions.get(0);
AttributeDefinition attributeDefinition = attributeDefinitions.getFirst();
assertEquals("baz", attributeDefinition.getAttributeName());
assertEquals("S", attributeDefinition.getAttributeType());

List<KeySchemaElement> keySchemas = createTableRequestCaptor.getValue().getKeySchema();
assertEquals(1, keySchemas.size());
KeySchemaElement keySchema = keySchemas.get(0);
KeySchemaElement keySchema = keySchemas.getFirst();
assertEquals("baz", keySchema.getAttributeName());
assertEquals("HASH", keySchema.getKeyType());

Expand Down
5 changes: 2 additions & 3 deletions ask-sdk-freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ private TemplateRendererException throwException(final String exceptionMessage,
final Map<String, Object> dataMap) {
String exceptionMsg = exceptionMessage + " with identifier: %s using data model map: %s with error: %s ";
if (LOGGER.isTraceEnabled()) {
String traceMsg = String.format(exceptionMsg + "with template content data: %s.",
String traceMsg = (exceptionMsg + "with template content data: %s.").formatted(
templateContentData.getIdentifier(), dataMap, e.getMessage(), templateContentData);
LOGGER.trace(traceMsg);
}
return new TemplateRendererException(String.format(exceptionMessage,
return new TemplateRendererException(exceptionMessage.formatted(
templateContentData.getIdentifier(), dataMap, e.getMessage()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
public class FreeMarkerRendererTest {

private static final String TEMPLATE =
"{\n" +
" \"type\": \"PlainText\",\n" +
" \"text\": \"${outputSpeechText}\"\n" +
"}";
"""
{
"type": "PlainText",
"text": "${outputSpeechText}"
}\
""";

private static final String EMPTY_TEMPLATE_JSON = "{ }";

Expand Down
7 changes: 3 additions & 4 deletions ask-sdk-lambda-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
Expand All @@ -71,11 +71,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
7 changes: 3 additions & 4 deletions ask-sdk-local-debug/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -97,11 +97,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<release>21</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void setSkillInvokerAndParamTypes() {
SkillHandlerType extendedClassType = SkillHandlerType
.getHandlerType(ReflectionUtils.getSuperClassName(skillInvokerClass));
if (extendedClassType == null) {
final String errorMessage = String.format("Extension type cannot be null");
final String errorMessage = "Extension type cannot be null".formatted();
LOG.error(errorMessage);
throw new LocalDebugSdkException(errorMessage);
}
Expand All @@ -165,7 +165,7 @@ private void setSkillInvokerAndParamTypes() {
paramTypes = new Class[]{InputStream.class, OutputStream.class, Context.class};
break;
default:
final String errorMessage = String.format("Unknown extension type - %s", extendedClassType);
final String errorMessage = "Unknown extension type - %s".formatted(extendedClassType);
LOG.error(errorMessage);
throw new LocalDebugSdkException(errorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ public URI connectCustomDebugEndpointUri() {
try {
endpointUrl = Region.valueOf(region.toUpperCase()).getEndpoint();
} catch (IllegalArgumentException ie) {
final String errorMessage = String.format("Invalid region - %1$s."
final String errorMessage = ("Invalid region - %1$s."
+ " Please ensure that the region value is one of "
+ "NorthAmerica, Europe or FarEast", region);
+ "NorthAmerica, Europe or FarEast").formatted(region);
LOG.error(errorMessage);
throw new LocalDebugSdkException(errorMessage);
}
return new URI(String.format(
Constants.CONNECT_CUSTOM_DEBUG_URI_SKELETON, endpointUrl,
return new URI(Constants.CONNECT_CUSTOM_DEBUG_URI_SKELETON.formatted(endpointUrl,
clientConfiguration.getSkillId()));
} catch (URISyntaxException e) {
LOG.error("Encountered error when constructing Uri", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public static Object getArgumentValue(
final List<String> argumentList,
final boolean isRequired,
final Object defaultValue) {
int index = argumentList.indexOf(String.format("--%s", argumentName));
int index = argumentList.indexOf("--%s".formatted(argumentName));
if (index == -1) {
if (isRequired) {
String error = String.format("Required argument - %s not provided.", argumentName);
String error = "Required argument - %s not provided.".formatted(argumentName);
LOG.error(error);
throw new LocalDebugSdkException(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Class<?> getClassReference(final String fullyQualifiedClassName) {
try {
return Class.forName(fullyQualifiedClassName);
} catch (ClassNotFoundException e) {
LOG.error(String.format("Class not found exception for class - %s", fullyQualifiedClassName), e.toString());
LOG.error("Class not found exception for class - %s".formatted(fullyQualifiedClassName), e.toString());

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

This LOG.error(...) call passes e.toString() as the second argument, which won’t log the stack trace (and may be ignored since the message has no {} placeholders). Pass the actual exception as the throwable parameter (or include it as the last arg) so the error is diagnosable.

Suggested change
LOG.error("Class not found exception for class - %s".formatted(fullyQualifiedClassName), e.toString());
LOG.error("Class not found exception for class - %s".formatted(fullyQualifiedClassName), e);

Copilot uses AI. Check for mistakes.
throw new LocalDebugSdkException(e.getMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void close() throws IOException {
}, skillResponseByteArray, new DebugLambdaContext());
break;
default:
final String errorMessage = String.format("Unknown skill configuration type - %s",
final String errorMessage = "Unknown skill configuration type - %s".formatted(
skillInvokerConfiguration.getType());
LOG.error(errorMessage);
throw new LocalDebugSdkException(errorMessage);
Expand Down
Loading
Loading