Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5cYR-0006DU-Cy for pljava-dev@arkaria.postgresql.org; Tue, 11 Aug 2020 22:15:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5cYO-0003nS-Ds for pljava-dev@arkaria.postgresql.org; Tue, 11 Aug 2020 22:15:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5cYN-0003nK-UQ for pljava-dev@lists.postgresql.org; Tue, 11 Aug 2020 22:15:32 +0000 Received: from anastigmatix.net ([68.171.219.55]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5cYE-0002vv-ST for pljava-dev@lists.postgresql.org; Tue, 11 Aug 2020 22:15:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oD/x1nJluxtPUBceb5i9EkCGhMHj71g5BBkScP7ME1M=; b=pcsMupiYsRGNtq5dD3S3L5rY4F A0atHWa01a7NqDVI4Hta20p4tFGr0iDuf6n+bMiwS92vblb94OYbORPUu45rmOrv2YMTtkI4Je/sM Uo01VjllIwAVfk6Trgo4isu5byJLlNJN/qZHlUckzs9JlM8xQpgy5Q8DzZ8uvpGSnpUosmXnfchQz t5/uZj/VCswfKWxlIhbzxi0T5XkYdX1n17Ux2Tvq7gLUCQ5mbg14Tfm2QseXuzJ1t1CX79gNKnwHR W9/1c7UchfG3JiU3H//hUjdsBWvjDA3BnYbbuJhkr1vzY935x1UAPwRWuIUv8nMdjxDM9/EKhmcV/ taPmKvyA==; Received: from [184.19.31.139] (port=60438) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k5cYC-00AFZt-H2; Tue, 11 Aug 2020 18:15:21 -0400 Subject: Re: PL/Java new build plugin To: Kartik Ohri References: <5F232EBB.9030208@anastigmatix.net> <5F278CCE.1090006@anastigmatix.net> <5F2897AF.9040909@anastigmatix.net> <5F2A29E4.2000803@anastigmatix.net> <5F2EB313.8090706@anastigmatix.net> <5F2EE97B.1030108@anastigmatix.net> <5F30B425.4020402@anastigmatix.net> Cc: pljava-dev@lists.postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5F331877.50407@anastigmatix.net> Date: Tue, 11 Aug 2020 18:15:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/11/20 14:49, Kartik Ohri wrote: > I have currently added this > https://github.com/amCap1712/pljava/commit/174dd71365986094a500d6dda4c832de78f90783. > Is this fine? I had to change the way error handling worked to avoid > creating a new functional interface. That looks like some of the right ideas shaping up. You definitely do NOT want "arguments = String.join(" ", argumentsList)". That's exactly how to create a mess that cannot be correctly reparsed into the original arguments, depending on what characters they contain. The proper model to think in always a list of individual arguments. That is the model the Java ProcessBuilder uses, and it is also the true native model in POSIX (and so in Linux and Mac OS). The native model in Windows is a single joined command line that the receiving program then has to reparse to get the original individual arguments correctly back, and the Java runtime itself will create the joined string for you (you still pass individual arguments to ProcessBuilder), but it needs help to do that correctly; I hope you are reviewing the code in Node.java that I mentioned earlier. The point is to do this transparently and correctly, so you start with a list of arguments, and the invoked program ultimately has a list of arguments, and that's the same as the starting list. Regarding the subprocess stdout and stderr, as a way of doing things in stages, I would suggest starting as simply as possible: just set them both to INHERIT, so they go straight to our own stdout and stderr, and we don't have to do anything with them, and can concentrate on getting the build working. As a later step, we could revisit that to capture output and funnel it into Maven's logging, probably applying some filtering first, to decide what should be logged as info, warn, or error (and ideally do a better job of that than nar-maven-plugin does). Capturing all of the output in a readAllBytes() is not the usual way to do that, because it's preferable to see the messages as they happen rather than all at the end (and if a process happens to generate a whole lot of output, readAllBytes uses a lot of memory). In that way, that makes this task different from getPgConfigProperty, where the point really was to just read all of the output from pg_config and return it. I see now that you have refactored that method in terms of this one, but that may just complicate things. It is ok to have a couple of different methods using ProcessBuilder but in different ways, as "run pg_config and return its output" and "run this arbitrary compiler or linker with its output going to the log" are sufficiently different tasks. Regards, -Chap