{"action":"created","comment":{"url":"https://api.github.com/repos/googlegsa/database/pulls/comments/115889527","pull_request_review_id":37466720,"id":115889527,"diff_hunk":"@@ -386,19 +395,80 @@ public void generateResponse(ResultSet rs, Response resp)\n         throws IOException, SQLException {\n       overrideContentType(rs, resp);\n       overrideDisplayUrl(rs, resp);\n-      Blob blob = rs.getBlob(getContentColumnName());\n-      InputStream in = blob.getBinaryStream();\n-      OutputStream out = resp.getOutputStream();\n-      com.google.enterprise.adaptor.IOHelper.copyStream(in, out);\n-      in.close();\n-      if (!(blob instanceof javax.sql.rowset.serial.SerialBlob)) {\n-        // SerialBlob is adamant about not supporting free\n-        try {\n-          blob.free();\n-        } catch (java.sql.SQLFeatureNotSupportedException | \n-            UnsupportedOperationException unsupported) {\n-          // let JVM garbage collection deal with it\n+\n+      ResultSetMetaData rsMetaData = rs.getMetaData();\n+      int columnType = Types.OTHER;\n+      int numberOfColumns = rsMetaData.getColumnCount();\n+      for (int i = 1; i < (numberOfColumns + 1); i++) {\n+        String columnName = rsMetaData.getColumnLabel(i);\n+        if (columnName.equals(getContentColumnName())) {\n+          columnType = rsMetaData.getColumnType(i);\n+          log.log(Level.FINEST, \"Name: {0}, Type: {1}\", new Object[] {columnName, columnType});\n+        }\n+      }\n+\n+      InputStream in = null;\n+      Clob clob = null;\n+      Blob blob = null;\n+      switch (columnType) {\n+        case Types.VARCHAR:\n+          Reader rd = rs.getCharacterStream(getContentColumnName());\n+          in = new ByteArrayInputStream(CharStreams.toString(rd).getBytes(Charsets.UTF_8));\n+          break;\n+        case Types.VARBINARY:\n+          in = rs.getBinaryStream(getContentColumnName());\n+          break;\n+        case Types.CLOB:\n+        case Types.LONGVARCHAR:\n+          clob = rs.getClob(getContentColumnName());","path":"src/com/google/enterprise/adaptor/database/ResponseGenerator.java","position":95,"original_position":95,"commit_id":"e4ab402decd60397fd6004b76ba937bbd4ed4a16","original_commit_id":"e4ab402decd60397fd6004b76ba937bbd4ed4a16","user":{"login":"wiarlawd","id":8528546,"avatar_url":"https://avatars3.githubusercontent.com/u/8528546?v=3","gravatar_id":"","url":"https://api.github.com/users/wiarlawd","html_url":"https://github.com/wiarlawd","followers_url":"https://api.github.com/users/wiarlawd/followers","following_url":"https://api.github.com/users/wiarlawd/following{/other_user}","gists_url":"https://api.github.com/users/wiarlawd/gists{/gist_id}","starred_url":"https://api.github.com/users/wiarlawd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiarlawd/subscriptions","organizations_url":"https://api.github.com/users/wiarlawd/orgs","repos_url":"https://api.github.com/users/wiarlawd/repos","events_url":"https://api.github.com/users/wiarlawd/events{/privacy}","received_events_url":"https://api.github.com/users/wiarlawd/received_events","type":"User","site_admin":false},"body":"No can do. LONGVARCHAR should call rs.getCharacterStream.","created_at":"2017-05-11T01:32:05Z","updated_at":"2017-05-11T02:04:50Z","html_url":"https://github.com/googlegsa/database/pull/10#discussion_r115889527","pull_request_url":"https://api.github.com/repos/googlegsa/database/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/googlegsa/database/pulls/comments/115889527"},"html":{"href":"https://github.com/googlegsa/database/pull/10#discussion_r115889527"},"pull_request":{"href":"https://api.github.com/repos/googlegsa/database/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/googlegsa/database/pulls/10","id":119927527,"html_url":"https://github.com/googlegsa/database/pull/10","diff_url":"https://github.com/googlegsa/database/pull/10.diff","patch_url":"https://github.com/googlegsa/database/pull/10.patch","issue_url":"https://api.github.com/repos/googlegsa/database/issues/10","number":10,"state":"open","locked":false,"title":"Handle both SQL BLOB and CLOB types","user":{"login":"srinicodebytes","id":10248813,"avatar_url":"https://avatars2.githubusercontent.com/u/10248813?v=3","gravatar_id":"","url":"https://api.github.com/users/srinicodebytes","html_url":"https://github.com/srinicodebytes","followers_url":"https://api.github.com/users/srinicodebytes/followers","following_url":"https://api.github.com/users/srinicodebytes/following{/other_user}","gists_url":"https://api.github.com/users/srinicodebytes/gists{/gist_id}","starred_url":"https://api.github.com/users/srinicodebytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinicodebytes/subscriptions","organizations_url":"https://api.github.com/users/srinicodebytes/orgs","repos_url":"https://api.github.com/users/srinicodebytes/repos","events_url":"https://api.github.com/users/srinicodebytes/events{/privacy}","received_events_url":"https://api.github.com/users/srinicodebytes/received_events","type":"User","site_admin":false},"body":"Fix b/25753195. BLOB mode in v4 should explicitly handle both\r\nSQL BLOB and CLOB types.","created_at":"2017-05-10T16:36:01Z","updated_at":"2017-05-11T02:04:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee2553b578d04d5f7de104a2d5b42315d30e2243","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/googlegsa/database/pulls/10/commits","review_comments_url":"https://api.github.com/repos/googlegsa/database/pulls/10/comments","review_comment_url":"https://api.github.com/repos/googlegsa/database/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googlegsa/database/issues/10/comments","statuses_url":"https://api.github.com/repos/googlegsa/database/statuses/e4ab402decd60397fd6004b76ba937bbd4ed4a16","head":{"label":"googlegsa:sri-clob","ref":"sri-clob","sha":"e4ab402decd60397fd6004b76ba937bbd4ed4a16","user":{"login":"googlegsa","id":8918378,"avatar_url":"https://avatars1.githubusercontent.com/u/8918378?v=3","gravatar_id":"","url":"https://api.github.com/users/googlegsa","html_url":"https://github.com/googlegsa","followers_url":"https://api.github.com/users/googlegsa/followers","following_url":"https://api.github.com/users/googlegsa/following{/other_user}","gists_url":"https://api.github.com/users/googlegsa/gists{/gist_id}","starred_url":"https://api.github.com/users/googlegsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlegsa/subscriptions","organizations_url":"https://api.github.com/users/googlegsa/orgs","repos_url":"https://api.github.com/users/googlegsa/repos","events_url":"https://api.github.com/users/googlegsa/events{/privacy}","received_events_url":"https://api.github.com/users/googlegsa/received_events","type":"Organization","site_admin":false},"repo":{"id":24728766,"name":"database","full_name":"googlegsa/database","owner":{"login":"googlegsa","id":8918378,"avatar_url":"https://avatars1.githubusercontent.com/u/8918378?v=3","gravatar_id":"","url":"https://api.github.com/users/googlegsa","html_url":"https://github.com/googlegsa","followers_url":"https://api.github.com/users/googlegsa/followers","following_url":"https://api.github.com/users/googlegsa/following{/other_user}","gists_url":"https://api.github.com/users/googlegsa/gists{/gist_id}","starred_url":"https://api.github.com/users/googlegsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlegsa/subscriptions","organizations_url":"https://api.github.com/users/googlegsa/orgs","repos_url":"https://api.github.com/users/googlegsa/repos","events_url":"https://api.github.com/users/googlegsa/events{/privacy}","received_events_url":"https://api.github.com/users/googlegsa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googlegsa/database","description":null,"fork":false,"url":"https://api.github.com/repos/googlegsa/database","forks_url":"https://api.github.com/repos/googlegsa/database/forks","keys_url":"https://api.github.com/repos/googlegsa/database/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googlegsa/database/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googlegsa/database/teams","hooks_url":"https://api.github.com/repos/googlegsa/database/hooks","issue_events_url":"https://api.github.com/repos/googlegsa/database/issues/events{/number}","events_url":"https://api.github.com/repos/googlegsa/database/events","assignees_url":"https://api.github.com/repos/googlegsa/database/assignees{/user}","branches_url":"https://api.github.com/repos/googlegsa/database/branches{/branch}","tags_url":"https://api.github.com/repos/googlegsa/database/tags","blobs_url":"https://api.github.com/repos/googlegsa/database/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googlegsa/database/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googlegsa/database/git/refs{/sha}","trees_url":"https://api.github.com/repos/googlegsa/database/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googlegsa/database/statuses/{sha}","languages_url":"https://api.github.com/repos/googlegsa/database/languages","stargazers_url":"https://api.github.com/repos/googlegsa/database/stargazers","contributors_url":"https://api.github.com/repos/googlegsa/database/contributors","subscribers_url":"https://api.github.com/repos/googlegsa/database/subscribers","subscription_url":"https://api.github.com/repos/googlegsa/database/subscription","commits_url":"https://api.github.com/repos/googlegsa/database/commits{/sha}","git_commits_url":"https://api.github.com/repos/googlegsa/database/git/commits{/sha}","comments_url":"https://api.github.com/repos/googlegsa/database/comments{/number}","issue_comment_url":"https://api.github.com/repos/googlegsa/database/issues/comments{/number}","contents_url":"https://api.github.com/repos/googlegsa/database/contents/{+path}","compare_url":"https://api.github.com/repos/googlegsa/database/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googlegsa/database/merges","archive_url":"https://api.github.com/repos/googlegsa/database/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googlegsa/database/downloads","issues_url":"https://api.github.com/repos/googlegsa/database/issues{/number}","pulls_url":"https://api.github.com/repos/googlegsa/database/pulls{/number}","milestones_url":"https://api.github.com/repos/googlegsa/database/milestones{/number}","notifications_url":"https://api.github.com/repos/googlegsa/database/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googlegsa/database/labels{/name}","releases_url":"https://api.github.com/repos/googlegsa/database/releases{/id}","deployments_url":"https://api.github.com/repos/googlegsa/database/deployments","created_at":"2014-10-02T17:22:45Z","updated_at":"2016-11-07T19:24:44Z","pushed_at":"2017-05-10T19:57:10Z","git_url":"git://github.com/googlegsa/database.git","ssh_url":"git@github.com:googlegsa/database.git","clone_url":"https://github.com/googlegsa/database.git","svn_url":"https://github.com/googlegsa/database","homepage":null,"size":365,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"googlegsa:master","ref":"master","sha":"ce089e933c56837e7de8ff2c9bb2db3518aa3461","user":{"login":"googlegsa","id":8918378,"avatar_url":"https://avatars1.githubusercontent.com/u/8918378?v=3","gravatar_id":"","url":"https://api.github.com/users/googlegsa","html_url":"https://github.com/googlegsa","followers_url":"https://api.github.com/users/googlegsa/followers","following_url":"https://api.github.com/users/googlegsa/following{/other_user}","gists_url":"https://api.github.com/users/googlegsa/gists{/gist_id}","starred_url":"https://api.github.com/users/googlegsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlegsa/subscriptions","organizations_url":"https://api.github.com/users/googlegsa/orgs","repos_url":"https://api.github.com/users/googlegsa/repos","events_url":"https://api.github.com/users/googlegsa/events{/privacy}","received_events_url":"https://api.github.com/users/googlegsa/received_events","type":"Organization","site_admin":false},"repo":{"id":24728766,"name":"database","full_name":"googlegsa/database","owner":{"login":"googlegsa","id":8918378,"avatar_url":"https://avatars1.githubusercontent.com/u/8918378?v=3","gravatar_id":"","url":"https://api.github.com/users/googlegsa","html_url":"https://github.com/googlegsa","followers_url":"https://api.github.com/users/googlegsa/followers","following_url":"https://api.github.com/users/googlegsa/following{/other_user}","gists_url":"https://api.github.com/users/googlegsa/gists{/gist_id}","starred_url":"https://api.github.com/users/googlegsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlegsa/subscriptions","organizations_url":"https://api.github.com/users/googlegsa/orgs","repos_url":"https://api.github.com/users/googlegsa/repos","events_url":"https://api.github.com/users/googlegsa/events{/privacy}","received_events_url":"https://api.github.com/users/googlegsa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googlegsa/database","description":null,"fork":false,"url":"https://api.github.com/repos/googlegsa/database","forks_url":"https://api.github.com/repos/googlegsa/database/forks","keys_url":"https://api.github.com/repos/googlegsa/database/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googlegsa/database/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googlegsa/database/teams","hooks_url":"https://api.github.com/repos/googlegsa/database/hooks","issue_events_url":"https://api.github.com/repos/googlegsa/database/issues/events{/number}","events_url":"https://api.github.com/repos/googlegsa/database/events","assignees_url":"https://api.github.com/repos/googlegsa/database/assignees{/user}","branches_url":"https://api.github.com/repos/googlegsa/database/branches{/branch}","tags_url":"https://api.github.com/repos/googlegsa/database/tags","blobs_url":"https://api.github.com/repos/googlegsa/database/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googlegsa/database/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googlegsa/database/git/refs{/sha}","trees_url":"https://api.github.com/repos/googlegsa/database/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googlegsa/database/statuses/{sha}","languages_url":"https://api.github.com/repos/googlegsa/database/languages","stargazers_url":"https://api.github.com/repos/googlegsa/database/stargazers","contributors_url":"https://api.github.com/repos/googlegsa/database/contributors","subscribers_url":"https://api.github.com/repos/googlegsa/database/subscribers","subscription_url":"https://api.github.com/repos/googlegsa/database/subscription","commits_url":"https://api.github.com/repos/googlegsa/database/commits{/sha}","git_commits_url":"https://api.github.com/repos/googlegsa/database/git/commits{/sha}","comments_url":"https://api.github.com/repos/googlegsa/database/comments{/number}","issue_comment_url":"https://api.github.com/repos/googlegsa/database/issues/comments{/number}","contents_url":"https://api.github.com/repos/googlegsa/database/contents/{+path}","compare_url":"https://api.github.com/repos/googlegsa/database/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googlegsa/database/merges","archive_url":"https://api.github.com/repos/googlegsa/database/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googlegsa/database/downloads","issues_url":"https://api.github.com/repos/googlegsa/database/issues{/number}","pulls_url":"https://api.github.com/repos/googlegsa/database/pulls{/number}","milestones_url":"https://api.github.com/repos/googlegsa/database/milestones{/number}","notifications_url":"https://api.github.com/repos/googlegsa/database/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googlegsa/database/labels{/name}","releases_url":"https://api.github.com/repos/googlegsa/database/releases{/id}","deployments_url":"https://api.github.com/repos/googlegsa/database/deployments","created_at":"2014-10-02T17:22:45Z","updated_at":"2016-11-07T19:24:44Z","pushed_at":"2017-05-10T19:57:10Z","git_url":"git://github.com/googlegsa/database.git","ssh_url":"git@github.com:googlegsa/database.git","clone_url":"https://github.com/googlegsa/database.git","svn_url":"https://github.com/googlegsa/database","homepage":null,"size":365,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/googlegsa/database/pulls/10"},"html":{"href":"https://github.com/googlegsa/database/pull/10"},"issue":{"href":"https://api.github.com/repos/googlegsa/database/issues/10"},"comments":{"href":"https://api.github.com/repos/googlegsa/database/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/googlegsa/database/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/googlegsa/database/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googlegsa/database/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/googlegsa/database/statuses/e4ab402decd60397fd6004b76ba937bbd4ed4a16"}}}}
{"actor":{"display_login":"wiarlawd"}}