You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Rafał Gała (JIRA)" <ji...@apache.org> on 2017/07/24 12:53:01 UTC
[jira] [Commented] (CAMEL-11590) Unnecessary connection opened when
using custom AS400ConnectionPool
[ https://issues.apache.org/jira/browse/CAMEL-11590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16098314#comment-16098314 ]
Rafał Gała commented on CAMEL-11590:
------------------------------------
Closing the issue. I made a mistake while checking a number of active connections to AS400. The default pool will not open any connections until used, but it is never used when the non default pool is provided :)
> Unnecessary connection opened when using custom AS400ConnectionPool
> -------------------------------------------------------------------
>
> Key: CAMEL-11590
> URL: https://issues.apache.org/jira/browse/CAMEL-11590
> Project: Camel
> Issue Type: Bug
> Components: camel-jt400
> Reporter: Rafał Gała
> Priority: Minor
> Attachments: Jt400Component.patch
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> When using a custom *AS400ConnectionPool* for *Jt400Component* (*connectionPool* URI parameter), an unnecessary connection is opened to an AS400 system nevertheless. This happens only when the *resolvePropertyPlaceholders* property is set to *true* (there are getters called by reflection at some point from *IntrospectionSupport* class).
> This connection will never be used when using a custom *AS400ConnectionPool*, as the *createEndpoint* method in Jt400Component class checks if we use custom or default pool:
> {code:java}
> @Override
> protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> properties) throws Exception {
> AS400ConnectionPool connectionPool;
> if (properties.containsKey(CONNECTION_POOL)) {
> LOG.trace("AS400ConnectionPool instance specified in the URI - will look it up.");
>
> // We have chosen to handle the connectionPool option ourselves, so
> // we must remove it from the given parameter list (see
> // http://camel.apache.org/writing-components.html)
> String poolId = properties.remove(CONNECTION_POOL).toString();
> connectionPool = EndpointHelper.resolveReferenceParameter(getCamelContext(), poolId, AS400ConnectionPool.class, true);
> } else {
> LOG.trace("No AS400ConnectionPool instance specified in the URI - one will be provided.");
> connectionPool = getConnectionPool();
> }
> String type = remaining.substring(remaining.lastIndexOf(".") + 1).toUpperCase();
> Jt400Endpoint endpoint = new Jt400Endpoint(uri, this, connectionPool);
> setProperties(endpoint, properties);
> endpoint.setType(Jt400Type.valueOf(type));
> return endpoint;
> }
> {code}
> and uses the one provided instead.
> I've attached a patch which changes behaviour of the *createEndpoint* method to close the previously initialized default connection when the provided one should be used instead. This is not a very elegant solution though.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)