{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/79267004","id":79267004,"diff_hunk":"@@ -724,9 +696,19 @@ private static Object convertToConnect(Schema schema, JsonNode jsonValue) {\n                     break;\n             }\n         }\n-        typeConverter = TO_CONNECT_CONVERTERS.get(schemaType);\n+\n+        final JsonToConnectTypeConverter typeConverter = TO_CONNECT_CONVERTERS.get(schemaType);\n         if (typeConverter == null)\n-            throw new DataException(\"Unknown schema type: \" + schema.type());\n+            throw new DataException(\"Unknown schema type: \" + schemaType);\n+\n+        if (jsonValue.isNull()) {\n+            assert schema != null; // otherwise we would have thrown above because of unknown schema type\n+            if (schema.isOptional())\n+                return null;\n+            if (schema.defaultValue() != null)\n+                return schema.defaultValue(); // any logical type conversions should already have been applied","path":"connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java","position":160,"original_position":160,"commit_id":"1e09c6431f11361e7f3a5af4c09a8174c3547669","original_commit_id":"1e09c6431f11361e7f3a5af4c09a8174c3547669","user":{"login":"rhauch","id":84732,"avatar_url":"https://avatars.githubusercontent.com/u/84732?v=3","gravatar_id":"","url":"https://api.github.com/users/rhauch","html_url":"https://github.com/rhauch","followers_url":"https://api.github.com/users/rhauch/followers","following_url":"https://api.github.com/users/rhauch/following{/other_user}","gists_url":"https://api.github.com/users/rhauch/gists{/gist_id}","starred_url":"https://api.github.com/users/rhauch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhauch/subscriptions","organizations_url":"https://api.github.com/users/rhauch/orgs","repos_url":"https://api.github.com/users/rhauch/repos","events_url":"https://api.github.com/users/rhauch/events{/privacy}","received_events_url":"https://api.github.com/users/rhauch/received_events","type":"User","site_admin":false},"body":"The order of considering optional vs default value is different than before. Was that intentional?","created_at":"2016-09-16T23:31:45Z","updated_at":"2016-09-16T23:31:45Z","html_url":"https://github.com/apache/kafka/pull/1872#discussion_r79267004","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/1872","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/79267004"},"html":{"href":"https://github.com/apache/kafka/pull/1872#discussion_r79267004"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/1872"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/1872","id":85653567,"html_url":"https://github.com/apache/kafka/pull/1872","diff_url":"https://github.com/apache/kafka/pull/1872.diff","patch_url":"https://github.com/apache/kafka/pull/1872.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/1872","number":1872,"state":"open","locked":false,"title":"KAFKA-4183: centralize checking for optional and default values to avoid bugs","user":{"login":"shikhar","id":74267,"avatar_url":"https://avatars.githubusercontent.com/u/74267?v=3","gravatar_id":"","url":"https://api.github.com/users/shikhar","html_url":"https://github.com/shikhar","followers_url":"https://api.github.com/users/shikhar/followers","following_url":"https://api.github.com/users/shikhar/following{/other_user}","gists_url":"https://api.github.com/users/shikhar/gists{/gist_id}","starred_url":"https://api.github.com/users/shikhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shikhar/subscriptions","organizations_url":"https://api.github.com/users/shikhar/orgs","repos_url":"https://api.github.com/users/shikhar/repos","events_url":"https://api.github.com/users/shikhar/events{/privacy}","received_events_url":"https://api.github.com/users/shikhar/received_events","type":"User","site_admin":false},"body":"Cleaner to just check once for optional & default value from the `convertToConnect()` function.\r\n\r\nIt also helps address an issue with conversions for logical type schemas that have default values and null as the included value. That test case is _probably_ not an issue in practice, since when using the `JsonConverter` to serialize a missing field with a default value, it will serialize the default value for the field. But in the face of JSON data streaming in from a topic being [generous on input, strict on output](http://tedwise.com/2009/05/27/generous-on-input-strict-on-output) seems best.","created_at":"2016-09-16T23:25:51Z","updated_at":"2016-09-16T23:31:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4923c54f7f2279081ffb5c7d0cee787ce0e2adcd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/1872/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/1872/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/1872/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/1e09c6431f11361e7f3a5af4c09a8174c3547669","head":{"label":"shikhar:kafka-4183","ref":"kafka-4183","sha":"1e09c6431f11361e7f3a5af4c09a8174c3547669","user":{"login":"shikhar","id":74267,"avatar_url":"https://avatars.githubusercontent.com/u/74267?v=3","gravatar_id":"","url":"https://api.github.com/users/shikhar","html_url":"https://github.com/shikhar","followers_url":"https://api.github.com/users/shikhar/followers","following_url":"https://api.github.com/users/shikhar/following{/other_user}","gists_url":"https://api.github.com/users/shikhar/gists{/gist_id}","starred_url":"https://api.github.com/users/shikhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shikhar/subscriptions","organizations_url":"https://api.github.com/users/shikhar/orgs","repos_url":"https://api.github.com/users/shikhar/repos","events_url":"https://api.github.com/users/shikhar/events{/privacy}","received_events_url":"https://api.github.com/users/shikhar/received_events","type":"User","site_admin":false},"repo":{"id":59165469,"name":"kafka","full_name":"shikhar/kafka","owner":{"login":"shikhar","id":74267,"avatar_url":"https://avatars.githubusercontent.com/u/74267?v=3","gravatar_id":"","url":"https://api.github.com/users/shikhar","html_url":"https://github.com/shikhar","followers_url":"https://api.github.com/users/shikhar/followers","following_url":"https://api.github.com/users/shikhar/following{/other_user}","gists_url":"https://api.github.com/users/shikhar/gists{/gist_id}","starred_url":"https://api.github.com/users/shikhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shikhar/subscriptions","organizations_url":"https://api.github.com/users/shikhar/orgs","repos_url":"https://api.github.com/users/shikhar/repos","events_url":"https://api.github.com/users/shikhar/events{/privacy}","received_events_url":"https://api.github.com/users/shikhar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shikhar/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/shikhar/kafka","forks_url":"https://api.github.com/repos/shikhar/kafka/forks","keys_url":"https://api.github.com/repos/shikhar/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shikhar/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shikhar/kafka/teams","hooks_url":"https://api.github.com/repos/shikhar/kafka/hooks","issue_events_url":"https://api.github.com/repos/shikhar/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/shikhar/kafka/events","assignees_url":"https://api.github.com/repos/shikhar/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/shikhar/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/shikhar/kafka/tags","blobs_url":"https://api.github.com/repos/shikhar/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shikhar/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shikhar/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/shikhar/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shikhar/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/shikhar/kafka/languages","stargazers_url":"https://api.github.com/repos/shikhar/kafka/stargazers","contributors_url":"https://api.github.com/repos/shikhar/kafka/contributors","subscribers_url":"https://api.github.com/repos/shikhar/kafka/subscribers","subscription_url":"https://api.github.com/repos/shikhar/kafka/subscription","commits_url":"https://api.github.com/repos/shikhar/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/shikhar/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/shikhar/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/shikhar/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/shikhar/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/shikhar/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shikhar/kafka/merges","archive_url":"https://api.github.com/repos/shikhar/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shikhar/kafka/downloads","issues_url":"https://api.github.com/repos/shikhar/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/shikhar/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/shikhar/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/shikhar/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shikhar/kafka/labels{/name}","releases_url":"https://api.github.com/repos/shikhar/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/shikhar/kafka/deployments","created_at":"2016-05-19T01:58:21Z","updated_at":"2016-05-19T01:58:25Z","pushed_at":"2016-09-16T23:17:47Z","git_url":"git://github.com/shikhar/kafka.git","ssh_url":"git@github.com:shikhar/kafka.git","clone_url":"https://github.com/shikhar/kafka.git","svn_url":"https://github.com/shikhar/kafka","homepage":null,"size":33132,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"d7bffebca05aa91a69da03fe29add4f29b964fd9","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":2211243,"name":"kafka","full_name":"apache/kafka","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2016-09-16T12:56:06Z","pushed_at":"2016-09-16T23:25:51Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":48681,"stargazers_count":3767,"watchers_count":3767,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2346,"mirror_url":"git://git.apache.org/kafka.git","open_issues_count":258,"forks":2346,"open_issues":258,"watchers":3767,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/1872"},"html":{"href":"https://github.com/apache/kafka/pull/1872"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/1872"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/1872/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/1872/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/1872/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/1e09c6431f11361e7f3a5af4c09a8174c3547669"}}}}
{"actor":{"display_login":"rhauch"}}