{"action":"created","comment":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/comments/72402185","id":72402185,"diff_hunk":"@@ -268,41 +267,38 @@ public static boolean containsWord(String word, String text) {\n      * possible if the search expression is not a regExp.\n      */\n     private void removeMatches(BibEntry entry) {\n-        if (!entry.hasField(searchField)) {\n-            return; // nothing to modify\n-        }\n-        String content = entry.getField(searchField);\n-        StringBuffer sbOrig = new StringBuffer(content);\n-        StringBuffer sbLower = new StringBuffer(content.toLowerCase());\n-        StringBuffer haystack = caseSensitive ? sbOrig : sbLower;\n-        String needle = caseSensitive ? searchExpression\n-                : searchExpression.toLowerCase();\n-        int i;\n-        int j;\n-        int k;\n-        final String separator = jabRefPreferences.get(JabRefPreferences.KEYWORD_SEPARATOR);\n-        while ((i = haystack.indexOf(needle)) >= 0) {\n-            sbOrig.replace(i, i + needle.length(), \"\");\n-            sbLower.replace(i, i + needle.length(), \"\");\n-            // reduce spaces at i to 1\n-            j = i;\n-            k = i;\n-            while (((j - 1) >= 0) && (separator.indexOf(haystack.charAt(j - 1)) >= 0)) {\n-                --j;\n-            }\n-            while ((k < haystack.length()) && (separator.indexOf(haystack.charAt(k)) >= 0)) {\n-                ++k;\n+        entry.getFieldOptional(searchField).ifPresent(content -> {\n+            StringBuffer sbOrig = new StringBuffer(content);\n+            StringBuffer sbLower = new StringBuffer(content.toLowerCase());\n+            StringBuffer haystack = caseSensitive ? sbOrig : sbLower;\n+            String needle = caseSensitive ? searchExpression : searchExpression.toLowerCase();","path":"src/main/java/net/sf/jabref/logic/groups/KeywordGroup.java","position":58,"original_position":58,"commit_id":"a1af14bc8f37cb99f9b54c0d8c683ad84e5bce0f","original_commit_id":"a1af14bc8f37cb99f9b54c0d8c683ad84e5bce0f","user":{"login":"Siedlerchr","id":320228,"avatar_url":"https://avatars.githubusercontent.com/u/320228?v=3","gravatar_id":"","url":"https://api.github.com/users/Siedlerchr","html_url":"https://github.com/Siedlerchr","followers_url":"https://api.github.com/users/Siedlerchr/followers","following_url":"https://api.github.com/users/Siedlerchr/following{/other_user}","gists_url":"https://api.github.com/users/Siedlerchr/gists{/gist_id}","starred_url":"https://api.github.com/users/Siedlerchr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Siedlerchr/subscriptions","organizations_url":"https://api.github.com/users/Siedlerchr/orgs","repos_url":"https://api.github.com/users/Siedlerchr/repos","events_url":"https://api.github.com/users/Siedlerchr/events{/privacy}","received_events_url":"https://api.github.com/users/Siedlerchr/received_events","type":"User","site_admin":false},"body":"What the hell is that for a method?\r\n![needlehaystack](https://cloud.githubusercontent.com/assets/320228/17169348/4cd11ee6-53e7-11e6-8746-e324f255a3e8.jpg)\r\n","created_at":"2016-07-27T08:46:06Z","updated_at":"2016-07-27T08:46:06Z","html_url":"https://github.com/JabRef/jabref/pull/1631#discussion_r72402185","pull_request_url":"https://api.github.com/repos/JabRef/jabref/pulls/1631","_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments/72402185"},"html":{"href":"https://github.com/JabRef/jabref/pull/1631#discussion_r72402185"},"pull_request":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1631"}}},"pull_request":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/1631","id":78928361,"html_url":"https://github.com/JabRef/jabref/pull/1631","diff_url":"https://github.com/JabRef/jabref/pull/1631.diff","patch_url":"https://github.com/JabRef/jabref/pull/1631.patch","issue_url":"https://api.github.com/repos/JabRef/jabref/issues/1631","number":1631,"state":"open","locked":false,"title":"Replaced some getField and fixed some bugs","user":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"body":"Thanks to @Siedlerchr reminding me about the brilliance of Optional, I decided to try and convert some BibEntry.getField to BibEntry.getFieldOptional in a \"proper\" way. I managed in a few positions, but more importantly i reinstalled Find bugs as a consequence of this. \r\n\r\nI found a few quite bad bugs, such as NPEs when clicking \"Browse\" in the journal management dialog with an empty text field. Also, there where some other example of introducing requireNonNull without really checking that all existing calling functions did call without a null hard coded...\r\n\r\n@Siedlerchr as I know that you are a big fan of Path, Find bugs complains that some method there is quite likely to return null (I think getPath()), so stacking a number of method calls is claimed to be risky.\r\n\r\nStill a few to be fixed (appending a database with explicit groups will most likely not work at the moment), but I leave that to the persons introducing them.\r\n\r\n- [x] Manually tested changed features in running JabRef\r\n\r\n","created_at":"2016-07-26T21:24:17Z","updated_at":"2016-07-27T08:46:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5283633b8930fa8d0ff6ca419d7c0e6364d10500","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JabRef/jabref/pulls/1631/commits","review_comments_url":"https://api.github.com/repos/JabRef/jabref/pulls/1631/comments","review_comment_url":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JabRef/jabref/issues/1631/comments","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/a1af14bc8f37cb99f9b54c0d8c683ad84e5bce0f","head":{"label":"oscargus:getfieldoptional","ref":"getfieldoptional","sha":"a1af14bc8f37cb99f9b54c0d8c683ad84e5bce0f","user":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"repo":{"id":43496954,"name":"jabref","full_name":"oscargus/jabref","owner":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oscargus/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":true,"url":"https://api.github.com/repos/oscargus/jabref","forks_url":"https://api.github.com/repos/oscargus/jabref/forks","keys_url":"https://api.github.com/repos/oscargus/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oscargus/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oscargus/jabref/teams","hooks_url":"https://api.github.com/repos/oscargus/jabref/hooks","issue_events_url":"https://api.github.com/repos/oscargus/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/oscargus/jabref/events","assignees_url":"https://api.github.com/repos/oscargus/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/oscargus/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/oscargus/jabref/tags","blobs_url":"https://api.github.com/repos/oscargus/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oscargus/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oscargus/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/oscargus/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oscargus/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/oscargus/jabref/languages","stargazers_url":"https://api.github.com/repos/oscargus/jabref/stargazers","contributors_url":"https://api.github.com/repos/oscargus/jabref/contributors","subscribers_url":"https://api.github.com/repos/oscargus/jabref/subscribers","subscription_url":"https://api.github.com/repos/oscargus/jabref/subscription","commits_url":"https://api.github.com/repos/oscargus/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/oscargus/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/oscargus/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/oscargus/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/oscargus/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/oscargus/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oscargus/jabref/merges","archive_url":"https://api.github.com/repos/oscargus/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oscargus/jabref/downloads","issues_url":"https://api.github.com/repos/oscargus/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/oscargus/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/oscargus/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/oscargus/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oscargus/jabref/labels{/name}","releases_url":"https://api.github.com/repos/oscargus/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/oscargus/jabref/deployments","created_at":"2015-10-01T13:07:32Z","updated_at":"2016-01-11T08:19:16Z","pushed_at":"2016-07-26T21:31:34Z","git_url":"git://github.com/oscargus/jabref.git","ssh_url":"git@github.com:oscargus/jabref.git","clone_url":"https://github.com/oscargus/jabref.git","svn_url":"https://github.com/oscargus/jabref","homepage":"http://jabref.sourceforge.net/","size":84929,"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":"JabRef:master","ref":"master","sha":"653c8a98d4e94ad13942599a1ab7d2e64374a7eb","user":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"repo":{"id":17634071,"name":"jabref","full_name":"JabRef/jabref","owner":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JabRef/jabref","description":"Graphical Java application for managing BibTeX and Biblatex (.bib) databases","fork":false,"url":"https://api.github.com/repos/JabRef/jabref","forks_url":"https://api.github.com/repos/JabRef/jabref/forks","keys_url":"https://api.github.com/repos/JabRef/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JabRef/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JabRef/jabref/teams","hooks_url":"https://api.github.com/repos/JabRef/jabref/hooks","issue_events_url":"https://api.github.com/repos/JabRef/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/JabRef/jabref/events","assignees_url":"https://api.github.com/repos/JabRef/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/JabRef/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/JabRef/jabref/tags","blobs_url":"https://api.github.com/repos/JabRef/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JabRef/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JabRef/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/JabRef/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/JabRef/jabref/languages","stargazers_url":"https://api.github.com/repos/JabRef/jabref/stargazers","contributors_url":"https://api.github.com/repos/JabRef/jabref/contributors","subscribers_url":"https://api.github.com/repos/JabRef/jabref/subscribers","subscription_url":"https://api.github.com/repos/JabRef/jabref/subscription","commits_url":"https://api.github.com/repos/JabRef/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/JabRef/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/JabRef/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/JabRef/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/JabRef/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/JabRef/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JabRef/jabref/merges","archive_url":"https://api.github.com/repos/JabRef/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JabRef/jabref/downloads","issues_url":"https://api.github.com/repos/JabRef/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/JabRef/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/JabRef/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/JabRef/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JabRef/jabref/labels{/name}","releases_url":"https://api.github.com/repos/JabRef/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/JabRef/jabref/deployments","created_at":"2014-03-11T14:48:42Z","updated_at":"2016-07-26T20:44:17Z","pushed_at":"2016-07-26T21:31:34Z","git_url":"git://github.com/JabRef/jabref.git","ssh_url":"git@github.com:JabRef/jabref.git","clone_url":"https://github.com/JabRef/jabref.git","svn_url":"https://github.com/JabRef/jabref","homepage":"http://www.jabref.org","size":91878,"stargazers_count":310,"watchers_count":310,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":181,"forks":245,"open_issues":181,"watchers":310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1631"},"html":{"href":"https://github.com/JabRef/jabref/pull/1631"},"issue":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1631"},"comments":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1631/comments"},"review_comments":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1631/comments"},"review_comment":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1631/commits"},"statuses":{"href":"https://api.github.com/repos/JabRef/jabref/statuses/a1af14bc8f37cb99f9b54c0d8c683ad84e5bce0f"}}}}
{"actor":{"display_login":"Siedlerchr"}}