Operations, requests and responses changes - Amazon SDK for Java 2.x
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Operations, requests and responses changes

In version 2 of the SDK for Java, requests are passed to a client operation. For example DynamoDbClient's PutItemRequest is passed to DynamoDbClient.putItem operation. These operations return a response from the Amazon Web Services service, such as a PutItemResponse.

Version 2 of the SDK for Java has the following changes from version 1.

  • Operations with multiple response pages now have a Paginator method for automatically iterating over all items in the response.

  • You cannot mutate requests and responses.

  • You must create requests and responses with a static builder method instead of a constructor. For example, version 1's new PutItemRequest().withTableName(...) is now PutItemRequest.builder().tableName(...).build().

  • Operations support a short-hand way to create requests: dynamoDbClient.putItem(request -> request.tableName(...)).

The following sections describe specific changes between version 1 and version 2. Some parameter type changes can be converted automatically using the migration tool, while other changes require manual updates to your code.