{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/865","repository_url":"https://api.github.com/repos/aws/aws-sdk-java-v2","labels_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/865/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/865/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/865/events","html_url":"https://github.com/aws/aws-sdk-java-v2/issues/865","id":383214801,"node_id":"MDU6SXNzdWUzODMyMTQ4MDE=","number":865,"title":"Dynamo's GetItemResponse#item() return an empty map if nothing found","user":{"login":"sedovalx","id":9218022,"node_id":"MDQ6VXNlcjkyMTgwMjI=","avatar_url":"https://avatars2.githubusercontent.com/u/9218022?v=4","gravatar_id":"","url":"https://api.github.com/users/sedovalx","html_url":"https://github.com/sedovalx","followers_url":"https://api.github.com/users/sedovalx/followers","following_url":"https://api.github.com/users/sedovalx/following{/other_user}","gists_url":"https://api.github.com/users/sedovalx/gists{/gist_id}","starred_url":"https://api.github.com/users/sedovalx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sedovalx/subscriptions","organizations_url":"https://api.github.com/users/sedovalx/orgs","repos_url":"https://api.github.com/users/sedovalx/repos","events_url":"https://api.github.com/users/sedovalx/events{/privacy}","received_events_url":"https://api.github.com/users/sedovalx/received_events","type":"User","site_admin":false},"labels":[{"id":636337194,"node_id":"MDU6TGFiZWw2MzYzMzcxOTQ=","url":"https://api.github.com/repos/aws/aws-sdk-java-v2/labels/Question","name":"Question","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-21T17:05:14Z","updated_at":"2018-11-21T19:56:27Z","closed_at":null,"author_association":"NONE","body":"I'm trying to get a Dynamo item by a primary key value. Here is my code:\r\n```\r\nDynamoDbClient client = null;\r\nString tableName = \"...\";\r\nString queryId = \"...\";\r\nMap<String, AttributeValue> key = new TreeMap<>();\r\nkey.put(\"query_id\", AttributeValue.builder().s(queryId).build());\r\nGetItemRequest request = GetItemRequest.builder()\r\n        .tableName(tableName)\r\n        .key(key)\r\n        .build();\r\nMap<String, AttributeValue> result = client.getItem(request).item();\r\n```\r\n\r\nI expect this code to assign `null` to the `result` variable if nothing is found by the `queryId` and to assign a not-null map otherwise.\r\n\r\nNow, the response's item contains an empty map if nothing is found and a map with filed values otherwise. As I see while debugging the actual http response contains an empty json object in the body in case of passing a non-existent `queryId` into the request. \r\n\r\nI'm looking for a way to reliably distinguish the case when the item is not found. Do I miss something? \r\n\r\n* AWS Java SDK version used:  2.1.0\r\n* JDK version used: 1.8.0_181\r\n* Operating System and version: MacOS 10.14.1 (18B75)\r\n"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/comments/440791060","html_url":"https://github.com/aws/aws-sdk-java-v2/issues/865#issuecomment-440791060","issue_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/865","id":440791060,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDc5MTA2MA==","user":{"login":"sedovalx","id":9218022,"node_id":"MDQ6VXNlcjkyMTgwMjI=","avatar_url":"https://avatars2.githubusercontent.com/u/9218022?v=4","gravatar_id":"","url":"https://api.github.com/users/sedovalx","html_url":"https://github.com/sedovalx","followers_url":"https://api.github.com/users/sedovalx/followers","following_url":"https://api.github.com/users/sedovalx/following{/other_user}","gists_url":"https://api.github.com/users/sedovalx/gists{/gist_id}","starred_url":"https://api.github.com/users/sedovalx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sedovalx/subscriptions","organizations_url":"https://api.github.com/users/sedovalx/orgs","repos_url":"https://api.github.com/users/sedovalx/repos","events_url":"https://api.github.com/users/sedovalx/events{/privacy}","received_events_url":"https://api.github.com/users/sedovalx/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T19:56:27Z","updated_at":"2018-11-21T19:56:27Z","author_association":"NONE","body":"I see. From that point of view, using a `@Notnull`/`@Nullable` annotation in such places seems the better approach than `Optional`. If a service change the response contract to make a value always present you may change the `@Nullable` annotation to `@Notnull` and it will be backward compatible also. Speaking of Kotlin, in that language it would be a self speaking and clear API. In the Java case, most IDEs will warn a user on dereferencing a value that is marked as `@Nullable` without a null check.\r\n\r\nI hope you guys will revisit this decision to check types of returned lists and maps."}}
{"actor":{"display_login":"sedovalx"}}