You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jduo (via GitHub)" <gi...@apache.org> on 2023/11/02 18:28:56 UTC
Re: [PR] GH-38460: [Java][FlightRPC] Add mTLS support for Flight SQL JDBC driver [arrow]
jduo commented on code in PR #38461:
URL: https://github.com/apache/arrow/pull/38461#discussion_r1380622748
##########
java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightServer.java:
##########
@@ -306,28 +329,63 @@ public Builder maxInboundMessageSize(int maxMessageSize) {
return this;
}
+ /**
+ * A small utility function to ensure that InputStream attributes.
+ * are closed if they are not null
+ * @param stream The InputStream to close (if it is not null).
+ */
+ private void closeInputStreamIfNotNull(InputStream stream) throws IOException {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+
/**
* Enable TLS on the server.
* @param certChain The certificate chain to use.
* @param key The private key to use.
*/
public Builder useTls(final File certChain, final File key) throws IOException {
+ closeInputStreamIfNotNull(this.certChain);
+ closeInputStreamIfNotNull(this.key);
Review Comment:
We should set these to null after closing, because there can be an exception opening the new inputs. So this would leave these fields in a bad state (holding closed streams).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org