{"action":"created","comment":{"url":"https://api.github.com/repos/twall/jna/pulls/comments/29140651","id":29140651,"diff_hunk":"@@ -0,0 +1,181 @@\n+/* Copyright (c) 2007 Timothy Wall, All Rights Reserved\n+ *\n+ * This library is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 2.1 of the License, or (at your option) any later version.\n+ *\n+ * This library is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ */\n+package com.sun.jna.platform.win32;\n+\n+import java.nio.ByteBuffer;\n+import java.util.Arrays;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.Future;\n+import java.util.concurrent.TimeUnit;\n+import java.util.logging.Logger;\n+\n+import org.junit.Test;\n+\n+import com.sun.jna.platform.win32.WinDef.ULONGByReference;\n+import com.sun.jna.platform.win32.WinNT.HANDLE;\n+import com.sun.jna.ptr.IntByReference;\n+\n+/**\n+ * @author lgoldstein\n+ */\n+public class NamedPipeTest extends AbstractWin32TestSupport {\n+    public NamedPipeTest() {\n+        super();\n+    }\n+\n+    @Test\n+    public void testNamedPipeServerAPI() {\n+        String    pipeName=\"\\\\\\\\.\\\\pipe\\\\\" + getCurrentTestName();\n+        HANDLE    hNamedPipe=Kernel32.INSTANCE.CreateNamedPipe(pipeName,\n+                WinBase.PIPE_ACCESS_DUPLEX,        // dwOpenMode\n+                WinBase.PIPE_TYPE_BYTE | WinBase.PIPE_READMODE_BYTE | WinBase.PIPE_WAIT,    // dwPipeMode\n+                1,    // nMaxInstances,\n+                Byte.MAX_VALUE,    // nOutBufferSize,\n+                Byte.MAX_VALUE,    // nInBufferSize,\n+                1000,    // nDefaultTimeOut,\n+                null);    // lpSecurityAttributes\n+        assertCallSucceeded(\"CreateNamedPipe\", !WinBase.INVALID_HANDLE_VALUE.equals(hNamedPipe));\n+\n+        // NOTE: we don't really care what the returned values are only that the call succeeds\n+        try {\n+            IntByReference    lpFlags=new IntByReference(0);\n+            IntByReference    lpOutBuffferSize=new IntByReference(0);\n+            IntByReference    lpInBufferSize=new IntByReference(0);\n+                IntByReference    lpMaxInstances=new IntByReference(0);\n+                assertCallSucceeded(\"GetNamedPipeInfo\",\n+                                    Kernel32.INSTANCE.GetNamedPipeInfo(hNamedPipe, lpFlags,\n+                                            lpOutBuffferSize, lpInBufferSize, lpMaxInstances));\n+\n+                ULONGByReference    ServerProcessId=new ULONGByReference();\n+                assertCallSucceeded(\"GetNamedPipeServerProcessId\", Kernel32.INSTANCE.GetNamedPipeServerProcessId(hNamedPipe, ServerProcessId));\n+\n+                ULONGByReference ServerSessionId=new ULONGByReference();\n+                assertCallSucceeded(\"GetNamedPipeServerSessionId\", Kernel32.INSTANCE.GetNamedPipeServerSessionId(hNamedPipe, ServerSessionId));\n+\n+                assertCallSucceeded(\"DisconnectNamedPipe\", Kernel32.INSTANCE.DisconnectNamedPipe(hNamedPipe));\n+        } finally {    // clean up\n+            assertCallSucceeded(\"Named pipe handle close\", Kernel32.INSTANCE.CloseHandle(hNamedPipe));","path":"contrib/platform/test/com/sun/jna/platform/win32/NamedPipeTest.java","position":68,"original_position":68,"commit_id":"75017876c4af72570bf12c3c72db918aab8d853c","original_commit_id":"7f9d08a5f958913e29ba93eea2d3c19fa6cf0afc","user":{"login":"dblock","id":542335,"avatar_url":"https://avatars.githubusercontent.com/u/542335?v=3","gravatar_id":"","url":"https://api.github.com/users/dblock","html_url":"https://github.com/dblock","followers_url":"https://api.github.com/users/dblock/followers","following_url":"https://api.github.com/users/dblock/following{/other_user}","gists_url":"https://api.github.com/users/dblock/gists{/gist_id}","starred_url":"https://api.github.com/users/dblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dblock/subscriptions","organizations_url":"https://api.github.com/users/dblock/orgs","repos_url":"https://api.github.com/users/dblock/repos","events_url":"https://api.github.com/users/dblock/events{/privacy}","received_events_url":"https://api.github.com/users/dblock/received_events","type":"User","site_admin":false},"body":"I understand, and again, feel free to leave it this way, but for argument-sake it's a test, I generally try to make these to be as simple as possible even if it means leaking handles when they fail. The process goes away after failure anyway. ","created_at":"2015-04-27T12:11:44Z","updated_at":"2015-04-27T12:11:44Z","html_url":"https://github.com/twall/jna/pull/431#discussion_r29140651","pull_request_url":"https://api.github.com/repos/twall/jna/pulls/431","_links":{"self":{"href":"https://api.github.com/repos/twall/jna/pulls/comments/29140651"},"html":{"href":"https://github.com/twall/jna/pull/431#discussion_r29140651"},"pull_request":{"href":"https://api.github.com/repos/twall/jna/pulls/431"}}},"pull_request":{"url":"https://api.github.com/repos/twall/jna/pulls/431","id":34156863,"html_url":"https://github.com/twall/jna/pull/431","diff_url":"https://github.com/twall/jna/pull/431.diff","patch_url":"https://github.com/twall/jna/pull/431.patch","issue_url":"https://api.github.com/repos/twall/jna/issues/431","number":431,"state":"open","locked":false,"title":"Added named pipe API support","user":{"login":"lgoldstein","id":1436205,"avatar_url":"https://avatars.githubusercontent.com/u/1436205?v=3","gravatar_id":"","url":"https://api.github.com/users/lgoldstein","html_url":"https://github.com/lgoldstein","followers_url":"https://api.github.com/users/lgoldstein/followers","following_url":"https://api.github.com/users/lgoldstein/following{/other_user}","gists_url":"https://api.github.com/users/lgoldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/lgoldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgoldstein/subscriptions","organizations_url":"https://api.github.com/users/lgoldstein/orgs","repos_url":"https://api.github.com/users/lgoldstein/repos","events_url":"https://api.github.com/users/lgoldstein/events{/privacy}","received_events_url":"https://api.github.com/users/lgoldstein/received_events","type":"User","site_admin":false},"body":"To do that I also added the following improvements:\r\n\r\n* Added definition of [FlushFileBuffers](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364439(v=vs.85).aspx)\r\n* Added _AbstractPlatformTestSupport_ along with an ability to retrieve the current test name\r\n* Added _AbstractWin32TestSupport_ and moved _assertCallSucceeded_ there since it is so typical of many calls.","created_at":"2015-04-27T10:36:54Z","updated_at":"2015-04-27T12:11:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8853d0a32393f05c954bfd782adc357640cbc371","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twall/jna/pulls/431/commits","review_comments_url":"https://api.github.com/repos/twall/jna/pulls/431/comments","review_comment_url":"https://api.github.com/repos/twall/jna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twall/jna/issues/431/comments","statuses_url":"https://api.github.com/repos/twall/jna/statuses/75017876c4af72570bf12c3c72db918aab8d853c","head":{"label":"lgoldstein:named-pipe","ref":"named-pipe","sha":"75017876c4af72570bf12c3c72db918aab8d853c","user":{"login":"lgoldstein","id":1436205,"avatar_url":"https://avatars.githubusercontent.com/u/1436205?v=3","gravatar_id":"","url":"https://api.github.com/users/lgoldstein","html_url":"https://github.com/lgoldstein","followers_url":"https://api.github.com/users/lgoldstein/followers","following_url":"https://api.github.com/users/lgoldstein/following{/other_user}","gists_url":"https://api.github.com/users/lgoldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/lgoldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgoldstein/subscriptions","organizations_url":"https://api.github.com/users/lgoldstein/orgs","repos_url":"https://api.github.com/users/lgoldstein/repos","events_url":"https://api.github.com/users/lgoldstein/events{/privacy}","received_events_url":"https://api.github.com/users/lgoldstein/received_events","type":"User","site_admin":false},"repo":{"id":34647172,"name":"jna","full_name":"lgoldstein/jna","owner":{"login":"lgoldstein","id":1436205,"avatar_url":"https://avatars.githubusercontent.com/u/1436205?v=3","gravatar_id":"","url":"https://api.github.com/users/lgoldstein","html_url":"https://github.com/lgoldstein","followers_url":"https://api.github.com/users/lgoldstein/followers","following_url":"https://api.github.com/users/lgoldstein/following{/other_user}","gists_url":"https://api.github.com/users/lgoldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/lgoldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgoldstein/subscriptions","organizations_url":"https://api.github.com/users/lgoldstein/orgs","repos_url":"https://api.github.com/users/lgoldstein/repos","events_url":"https://api.github.com/users/lgoldstein/events{/privacy}","received_events_url":"https://api.github.com/users/lgoldstein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lgoldstein/jna","description":"Java Native Access","fork":true,"url":"https://api.github.com/repos/lgoldstein/jna","forks_url":"https://api.github.com/repos/lgoldstein/jna/forks","keys_url":"https://api.github.com/repos/lgoldstein/jna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lgoldstein/jna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lgoldstein/jna/teams","hooks_url":"https://api.github.com/repos/lgoldstein/jna/hooks","issue_events_url":"https://api.github.com/repos/lgoldstein/jna/issues/events{/number}","events_url":"https://api.github.com/repos/lgoldstein/jna/events","assignees_url":"https://api.github.com/repos/lgoldstein/jna/assignees{/user}","branches_url":"https://api.github.com/repos/lgoldstein/jna/branches{/branch}","tags_url":"https://api.github.com/repos/lgoldstein/jna/tags","blobs_url":"https://api.github.com/repos/lgoldstein/jna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lgoldstein/jna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lgoldstein/jna/git/refs{/sha}","trees_url":"https://api.github.com/repos/lgoldstein/jna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lgoldstein/jna/statuses/{sha}","languages_url":"https://api.github.com/repos/lgoldstein/jna/languages","stargazers_url":"https://api.github.com/repos/lgoldstein/jna/stargazers","contributors_url":"https://api.github.com/repos/lgoldstein/jna/contributors","subscribers_url":"https://api.github.com/repos/lgoldstein/jna/subscribers","subscription_url":"https://api.github.com/repos/lgoldstein/jna/subscription","commits_url":"https://api.github.com/repos/lgoldstein/jna/commits{/sha}","git_commits_url":"https://api.github.com/repos/lgoldstein/jna/git/commits{/sha}","comments_url":"https://api.github.com/repos/lgoldstein/jna/comments{/number}","issue_comment_url":"https://api.github.com/repos/lgoldstein/jna/issues/comments{/number}","contents_url":"https://api.github.com/repos/lgoldstein/jna/contents/{+path}","compare_url":"https://api.github.com/repos/lgoldstein/jna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lgoldstein/jna/merges","archive_url":"https://api.github.com/repos/lgoldstein/jna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lgoldstein/jna/downloads","issues_url":"https://api.github.com/repos/lgoldstein/jna/issues{/number}","pulls_url":"https://api.github.com/repos/lgoldstein/jna/pulls{/number}","milestones_url":"https://api.github.com/repos/lgoldstein/jna/milestones{/number}","notifications_url":"https://api.github.com/repos/lgoldstein/jna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lgoldstein/jna/labels{/name}","releases_url":"https://api.github.com/repos/lgoldstein/jna/releases{/id}","created_at":"2015-04-27T05:09:04Z","updated_at":"2015-04-27T05:09:08Z","pushed_at":"2015-04-27T11:51:28Z","git_url":"git://github.com/lgoldstein/jna.git","ssh_url":"git@github.com:lgoldstein/jna.git","clone_url":"https://github.com/lgoldstein/jna.git","svn_url":"https://github.com/lgoldstein/jna","homepage":"","size":224055,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"twall:master","ref":"master","sha":"55106db8e9698665ebf47c69bfbd95164b438b0a","user":{"login":"twall","id":756909,"avatar_url":"https://avatars.githubusercontent.com/u/756909?v=3","gravatar_id":"","url":"https://api.github.com/users/twall","html_url":"https://github.com/twall","followers_url":"https://api.github.com/users/twall/followers","following_url":"https://api.github.com/users/twall/following{/other_user}","gists_url":"https://api.github.com/users/twall/gists{/gist_id}","starred_url":"https://api.github.com/users/twall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twall/subscriptions","organizations_url":"https://api.github.com/users/twall/orgs","repos_url":"https://api.github.com/users/twall/repos","events_url":"https://api.github.com/users/twall/events{/privacy}","received_events_url":"https://api.github.com/users/twall/received_events","type":"User","site_admin":false},"repo":{"id":1680733,"name":"jna","full_name":"twall/jna","owner":{"login":"twall","id":756909,"avatar_url":"https://avatars.githubusercontent.com/u/756909?v=3","gravatar_id":"","url":"https://api.github.com/users/twall","html_url":"https://github.com/twall","followers_url":"https://api.github.com/users/twall/followers","following_url":"https://api.github.com/users/twall/following{/other_user}","gists_url":"https://api.github.com/users/twall/gists{/gist_id}","starred_url":"https://api.github.com/users/twall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twall/subscriptions","organizations_url":"https://api.github.com/users/twall/orgs","repos_url":"https://api.github.com/users/twall/repos","events_url":"https://api.github.com/users/twall/events{/privacy}","received_events_url":"https://api.github.com/users/twall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/twall/jna","description":"Java Native Access","fork":false,"url":"https://api.github.com/repos/twall/jna","forks_url":"https://api.github.com/repos/twall/jna/forks","keys_url":"https://api.github.com/repos/twall/jna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twall/jna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twall/jna/teams","hooks_url":"https://api.github.com/repos/twall/jna/hooks","issue_events_url":"https://api.github.com/repos/twall/jna/issues/events{/number}","events_url":"https://api.github.com/repos/twall/jna/events","assignees_url":"https://api.github.com/repos/twall/jna/assignees{/user}","branches_url":"https://api.github.com/repos/twall/jna/branches{/branch}","tags_url":"https://api.github.com/repos/twall/jna/tags","blobs_url":"https://api.github.com/repos/twall/jna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twall/jna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twall/jna/git/refs{/sha}","trees_url":"https://api.github.com/repos/twall/jna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twall/jna/statuses/{sha}","languages_url":"https://api.github.com/repos/twall/jna/languages","stargazers_url":"https://api.github.com/repos/twall/jna/stargazers","contributors_url":"https://api.github.com/repos/twall/jna/contributors","subscribers_url":"https://api.github.com/repos/twall/jna/subscribers","subscription_url":"https://api.github.com/repos/twall/jna/subscription","commits_url":"https://api.github.com/repos/twall/jna/commits{/sha}","git_commits_url":"https://api.github.com/repos/twall/jna/git/commits{/sha}","comments_url":"https://api.github.com/repos/twall/jna/comments{/number}","issue_comment_url":"https://api.github.com/repos/twall/jna/issues/comments{/number}","contents_url":"https://api.github.com/repos/twall/jna/contents/{+path}","compare_url":"https://api.github.com/repos/twall/jna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twall/jna/merges","archive_url":"https://api.github.com/repos/twall/jna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twall/jna/downloads","issues_url":"https://api.github.com/repos/twall/jna/issues{/number}","pulls_url":"https://api.github.com/repos/twall/jna/pulls{/number}","milestones_url":"https://api.github.com/repos/twall/jna/milestones{/number}","notifications_url":"https://api.github.com/repos/twall/jna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twall/jna/labels{/name}","releases_url":"https://api.github.com/repos/twall/jna/releases{/id}","created_at":"2011-04-29T13:30:29Z","updated_at":"2015-04-27T11:05:57Z","pushed_at":"2015-04-27T11:49:50Z","git_url":"git://github.com/twall/jna.git","ssh_url":"git@github.com:twall/jna.git","clone_url":"https://github.com/twall/jna.git","svn_url":"https://github.com/twall/jna","homepage":"","size":224055,"stargazers_count":1641,"watchers_count":1641,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":468,"mirror_url":null,"open_issues_count":76,"forks":468,"open_issues":76,"watchers":1641,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/twall/jna/pulls/431"},"html":{"href":"https://github.com/twall/jna/pull/431"},"issue":{"href":"https://api.github.com/repos/twall/jna/issues/431"},"comments":{"href":"https://api.github.com/repos/twall/jna/issues/431/comments"},"review_comments":{"href":"https://api.github.com/repos/twall/jna/pulls/431/comments"},"review_comment":{"href":"https://api.github.com/repos/twall/jna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twall/jna/pulls/431/commits"},"statuses":{"href":"https://api.github.com/repos/twall/jna/statuses/75017876c4af72570bf12c3c72db918aab8d853c"}}}}