[
https://issues.apache.org/jira/browse/CAMEL-26198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136899#comment-18136899
]
Claus Ibsen commented on CAMEL-26198:
-------------------------------------
PR: https://github.com/apache/camel/pull/29023
1. A singleton InitialDirContext bean now fails on the next exchange with a
clear IllegalStateException (use a prototype scoped bean, or a Hashtable/Map
bean). The producer still closes the DirContext after each use, as decided in
CAMEL-1583: not closing it would leak a connection per exchange for
prototype/@Dependent beans. The docs and the dirContextName description say so,
and the credentials example binds the environment instead of a singleton
context.
2. A missing bean now fails with NoSuchBeanException naming the bean, instead
of an NPE.
3. The ITs start again: the test DirectoryExtension replaced the TLS key
without the tlsKeyInfo object class (ERR_277); that obsolete Java 8 workaround
is removed. The ITs are still gated by -Denable.ldap.itests=true.
Open question: should a singleton DirContext bean be supported, e.g. with an
option such as closeDirContext=false?
_Claude Code on behalf of Claus Ibsen (davsclaus)_
> camel-ldap - a DirContext bean is closed after the first exchange so the
> second fails, and a missing dirContextName bean gives an NPE
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26198
> URL: https://issues.apache.org/jira/browse/CAMEL-26198
> Project: Camel
> Issue Type: Bug
> Components: camel-ldap
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of ldap (CAMEL-24961, PR #28416).
> h4. 1. A DirContext bean is closed after the first exchange
> {{LdapProducer.process}} (main 2a465aa4814c, line 89 to 92) always closes the
> DirContext in a finally block. When the bean in the registry is a DirContext
> (not a Hashtable or Map), the javadoc of {{dirContextName}} ({{LdapEndpoint}}
> line 77 to 82) says "the bean is used as given", but the second exchange
> fails with NoInitialContextException because the bean was closed. Checked on
> 4.24.0-SNAPSHOT with a local OpenLDAP container (osixia/openldap 1.5.0).
> Proposed: close only the contexts the producer created from a Hashtable or
> Map; leave a DirContext bean open (or document that it must be prototype
> scoped).
> h4. 2. No bean for dirContextName gives an NPE
> When no bean is found, {{LdapProducer.getDirContext}} (line 106 to 120)
> returns null, and the search fails with the NullPointerException "ldapContext
> is null" instead of a clear error. Checked on 4.24.0-SNAPSHOT with a route
> with a dirContextName that is not in the registry.
> Proposed: throw NoSuchBeanException naming the bean when the lookup returns
> null.
> h4. 3. The embedded ApacheDS setup of the module ITs does not start
> The embedded ApacheDS of {{LdapRouteManualIT}} (and {{LdapRouteTwoManualIT}})
> fails in beforeAll with "ERR_277 Attribute publicKey not declared", so the
> module ITs cannot run. Checked on 4.24.0-SNAPSHOT with the module ITs on
> 4.24.0-SNAPSHOT.
> Proposed: fix the schema of the embedded server (or move the ITs to the
> openldap test-infra service).
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)