Github user MikeThomsen commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2553#discussion_r174874448
--- Diff:
nifi-nar-bundles/nifi-pulsar-bundle/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/pool/ResourcePoolImpl.java
---
@@ -0,0 +1,138 @@
+/*
+ * 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.pulsar.pool;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+public class ResourcePoolImpl<R extends PoolableResource> implements
ResourcePool<R> {
+
+ private final Lock lock = new ReentrantLock();
+ private final Condition poolAvailable = lock.newCondition();
+ private int max_resources;
+ private final Vector<R> pool;
+
+ private final ResourceExceptionHandler resourceExceptionHandler;
+ private final ResourceFactory<R> factory;
+
+ public ResourcePoolImpl(ResourceFactory<R> factory, int max_resources)
{
+ this(factory, new ResourceExceptionHandlerImpl(),
max_resources);
+ }
+
+ public ResourcePoolImpl(ResourceFactory<R> factory,
ResourceExceptionHandler handler, int max_resources) {
+ lock.lock();
+ try {
+ this.factory = factory;
+ this.resourceExceptionHandler = handler;
+ this.max_resources = max_resources;
+ this.pool = new Vector<R>(max_resources);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private R createResource(Properties props) {
+ R resource = null;
+ try {
+
+ resource = factory.create(props);
--- End diff --
There's some extraneous white space around this.
---