dam4rus commented on code in PR #6584: URL: https://github.com/apache/nifi/pull/6584#discussion_r1017813657
########## nifi-nar-bundles/nifi-snowflake-bundle/nifi-snowflake-services-api/src/main/java/org/apache/nifi/processors/snowflake/SnowflakeConnectionWrapper.java: ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.processors.snowflake; + +import java.sql.Connection; +import java.sql.SQLException; +import net.snowflake.client.jdbc.SnowflakeConnection; + +public class SnowflakeConnectionWrapper implements AutoCloseable { Review Comment: The issue with returning a `Connection` is that we need to unwrap it into a `SnowflakeConnection` interface in the processors `onTrigger` to enable uploading `Stream`s. But this hasn't worked worked for me because the `Connection` instance is of a class in the service-api-nar, not the processors-nar. This caused an exception when calling `Connection.unwrap`. Tried annotating the processor with `@RequiresInstanceClassLoading` as well but haven't solved the issue. Maybe there's a solution I don't know about? As for the `AutoCloseable`: We could return a `SnowflakeConnection` instance but `SnowflakeConnection` doesn't implements `AutoCloseable`. So there's no way to close the connection via a `SnowflakeConnection` instance. This is a workaround to enable closing the connection while also providing a way to unwrap the connection -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
