{"action":"opened","number":23,"pull_request":{"url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23","id":40528560,"html_url":"https://github.com/MariaDB/mariadb-connector-j/pull/23","diff_url":"https://github.com/MariaDB/mariadb-connector-j/pull/23.diff","patch_url":"https://github.com/MariaDB/mariadb-connector-j/pull/23.patch","issue_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/23","number":23,"state":"open","locked":false,"title":"Removed Sometimes Unnecessary String Instantiation That Can Cause Thread Blocking","user":{"login":"andysenn","id":6332973,"avatar_url":"https://avatars.githubusercontent.com/u/6332973?v=3","gravatar_id":"","url":"https://api.github.com/users/andysenn","html_url":"https://github.com/andysenn","followers_url":"https://api.github.com/users/andysenn/followers","following_url":"https://api.github.com/users/andysenn/following{/other_user}","gists_url":"https://api.github.com/users/andysenn/gists{/gist_id}","starred_url":"https://api.github.com/users/andysenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andysenn/subscriptions","organizations_url":"https://api.github.com/users/andysenn/orgs","repos_url":"https://api.github.com/users/andysenn/repos","events_url":"https://api.github.com/users/andysenn/events{/privacy}","received_events_url":"https://api.github.com/users/andysenn/received_events","type":"User","site_admin":false},"body":"Resolved an issue where several concurrent reads of large byte arrays from a result set could cause threads to back up in a synchronization queue.\r\n\r\nCalling #getBytes(...) on the result set makes a call to  #getValueObject(...), which calls AbstractValueObject#isNull(). The existing workflow was as follows:\r\n\r\n1) Declare 'rawValue' and set it to the return value of #getString() <- This can cause issues as described below\r\n2) Declare 'zeroTimestamp' and set it\r\n3) Declare 'zeroDate' and set it\r\n4.1) If 'rawBytes' is null, return true\r\n4.2) If the datatype is either TIMESTAMP or DATETIME, check for equality between 'rawValue' and 'zeroTimestamp'. If true, return true\r\n4.3) If the datatype is DATE, check for equality between 'rawValue' and 'zeroDate'. If true, return true\r\n4.4) Otherwise, return false\r\n\r\nIn this workflow, we make a call to #getString() whether we end up needing its return value or not.\r\n\r\nCalling #getString() executes a chain of method calls that eventually end up at java.nio.charset.CoderResult$Cache.get(int). In the middle of this call stack is a call from java.lang.StringCoding to a statically referenced instance of java.lang.StringCoding$StringDecoder. Transitively, this means that it ends up using the same instance of java.nio.charset.CoderResult$Cache. Since $Cache#get(int) is synchronized, this can cause threads to back up in a high-traffic environment.\r\n\r\nThis issue is exacerbated by the fact that it is run within the context of an open database connection. If using database connection pooling, enough threads can pile up in the synchronization pool that the database connection pool is effectively exhausted. Requests for database connections can continue to enqueue until the JVM exhausts its heap and becomes unstable.\r\n\r\nSince the return value of #getString() is only used when the data type is DATE, DATETIME, or TIMESTAMP, its invocation is unnecessary in other cases. Instead of calling it unconditionally, I replaced the occurrences of 'rawValue' in the conditions with calls to #getString(). Since the data type will either be DATE -or- (DATETIME or TIMESTAMP), it would not be possible for the invocation to occur twice as that condition would short-circuit the && condition of zeroXXX.equals(rawValue).","created_at":"2015-07-22T04:05:02Z","updated_at":"2015-07-22T04:05:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23/commits","review_comments_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23/comments","review_comment_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/23/comments","statuses_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/statuses/04f17cc70c1316b945be874a731feb6e3a52716b","head":{"label":"andysenn:master","ref":"master","sha":"04f17cc70c1316b945be874a731feb6e3a52716b","user":{"login":"andysenn","id":6332973,"avatar_url":"https://avatars.githubusercontent.com/u/6332973?v=3","gravatar_id":"","url":"https://api.github.com/users/andysenn","html_url":"https://github.com/andysenn","followers_url":"https://api.github.com/users/andysenn/followers","following_url":"https://api.github.com/users/andysenn/following{/other_user}","gists_url":"https://api.github.com/users/andysenn/gists{/gist_id}","starred_url":"https://api.github.com/users/andysenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andysenn/subscriptions","organizations_url":"https://api.github.com/users/andysenn/orgs","repos_url":"https://api.github.com/users/andysenn/repos","events_url":"https://api.github.com/users/andysenn/events{/privacy}","received_events_url":"https://api.github.com/users/andysenn/received_events","type":"User","site_admin":false},"repo":{"id":39474265,"name":"mariadb-connector-j","full_name":"andysenn/mariadb-connector-j","owner":{"login":"andysenn","id":6332973,"avatar_url":"https://avatars.githubusercontent.com/u/6332973?v=3","gravatar_id":"","url":"https://api.github.com/users/andysenn","html_url":"https://github.com/andysenn","followers_url":"https://api.github.com/users/andysenn/followers","following_url":"https://api.github.com/users/andysenn/following{/other_user}","gists_url":"https://api.github.com/users/andysenn/gists{/gist_id}","starred_url":"https://api.github.com/users/andysenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andysenn/subscriptions","organizations_url":"https://api.github.com/users/andysenn/orgs","repos_url":"https://api.github.com/users/andysenn/repos","events_url":"https://api.github.com/users/andysenn/events{/privacy}","received_events_url":"https://api.github.com/users/andysenn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andysenn/mariadb-connector-j","description":"MariaDB Connector/J is used to connect applications developed in Java to MariaDB and MySQL databases. MariaDB Connector/J is LGPL licensed.","fork":true,"url":"https://api.github.com/repos/andysenn/mariadb-connector-j","forks_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/forks","keys_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/teams","hooks_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/hooks","issue_events_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/issues/events{/number}","events_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/events","assignees_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/assignees{/user}","branches_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/branches{/branch}","tags_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/tags","blobs_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/git/refs{/sha}","trees_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/statuses/{sha}","languages_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/languages","stargazers_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/stargazers","contributors_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/contributors","subscribers_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/subscribers","subscription_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/subscription","commits_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/commits{/sha}","git_commits_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/git/commits{/sha}","comments_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/comments{/number}","issue_comment_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/issues/comments{/number}","contents_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/contents/{+path}","compare_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/merges","archive_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/downloads","issues_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/issues{/number}","pulls_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/pulls{/number}","milestones_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/milestones{/number}","notifications_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/labels{/name}","releases_url":"https://api.github.com/repos/andysenn/mariadb-connector-j/releases{/id}","created_at":"2015-07-21T23:08:22Z","updated_at":"2015-07-21T23:08:23Z","pushed_at":"2015-07-22T04:01:08Z","git_url":"git://github.com/andysenn/mariadb-connector-j.git","ssh_url":"git@github.com:andysenn/mariadb-connector-j.git","clone_url":"https://github.com/andysenn/mariadb-connector-j.git","svn_url":"https://github.com/andysenn/mariadb-connector-j","homepage":null,"size":3257,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"MariaDB:master","ref":"master","sha":"4419ac044cfa609e01d491218ef6751b2bb8537f","user":{"login":"MariaDB","id":4739304,"avatar_url":"https://avatars.githubusercontent.com/u/4739304?v=3","gravatar_id":"","url":"https://api.github.com/users/MariaDB","html_url":"https://github.com/MariaDB","followers_url":"https://api.github.com/users/MariaDB/followers","following_url":"https://api.github.com/users/MariaDB/following{/other_user}","gists_url":"https://api.github.com/users/MariaDB/gists{/gist_id}","starred_url":"https://api.github.com/users/MariaDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MariaDB/subscriptions","organizations_url":"https://api.github.com/users/MariaDB/orgs","repos_url":"https://api.github.com/users/MariaDB/repos","events_url":"https://api.github.com/users/MariaDB/events{/privacy}","received_events_url":"https://api.github.com/users/MariaDB/received_events","type":"Organization","site_admin":false},"repo":{"id":30072532,"name":"mariadb-connector-j","full_name":"MariaDB/mariadb-connector-j","owner":{"login":"MariaDB","id":4739304,"avatar_url":"https://avatars.githubusercontent.com/u/4739304?v=3","gravatar_id":"","url":"https://api.github.com/users/MariaDB","html_url":"https://github.com/MariaDB","followers_url":"https://api.github.com/users/MariaDB/followers","following_url":"https://api.github.com/users/MariaDB/following{/other_user}","gists_url":"https://api.github.com/users/MariaDB/gists{/gist_id}","starred_url":"https://api.github.com/users/MariaDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MariaDB/subscriptions","organizations_url":"https://api.github.com/users/MariaDB/orgs","repos_url":"https://api.github.com/users/MariaDB/repos","events_url":"https://api.github.com/users/MariaDB/events{/privacy}","received_events_url":"https://api.github.com/users/MariaDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MariaDB/mariadb-connector-j","description":"MariaDB Connector/J is used to connect applications developed in Java to MariaDB and MySQL databases. MariaDB Connector/J is LGPL licensed.","fork":false,"url":"https://api.github.com/repos/MariaDB/mariadb-connector-j","forks_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/forks","keys_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/teams","hooks_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/hooks","issue_events_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/events{/number}","events_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/events","assignees_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/assignees{/user}","branches_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/branches{/branch}","tags_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/tags","blobs_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/git/refs{/sha}","trees_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/statuses/{sha}","languages_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/languages","stargazers_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/stargazers","contributors_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/contributors","subscribers_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/subscribers","subscription_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/subscription","commits_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/commits{/sha}","git_commits_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/git/commits{/sha}","comments_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/comments{/number}","issue_comment_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/comments{/number}","contents_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/contents/{+path}","compare_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/merges","archive_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/downloads","issues_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues{/number}","pulls_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls{/number}","milestones_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/milestones{/number}","notifications_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/labels{/name}","releases_url":"https://api.github.com/repos/MariaDB/mariadb-connector-j/releases{/id}","created_at":"2015-01-30T13:12:38Z","updated_at":"2015-06-28T18:33:47Z","pushed_at":"2015-07-21T09:58:20Z","git_url":"git://github.com/MariaDB/mariadb-connector-j.git","ssh_url":"git@github.com:MariaDB/mariadb-connector-j.git","clone_url":"https://github.com/MariaDB/mariadb-connector-j.git","svn_url":"https://github.com/MariaDB/mariadb-connector-j","homepage":null,"size":3257,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":3,"forks":18,"open_issues":3,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23"},"html":{"href":"https://github.com/MariaDB/mariadb-connector-j/pull/23"},"issue":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/23"},"comments":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/MariaDB/mariadb-connector-j/statuses/04f17cc70c1316b945be874a731feb6e3a52716b"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":2,"deletions":3,"changed_files":1}}