diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java index 037e61c37..084e0522e 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java @@ -252,12 +252,15 @@ public void search(String base, String filter, int searchScope, boolean returnin @Override public void search(final Name base, final String filter, final SearchControls controls, NameClassPairCallbackHandler handler) { - + SearchExecutor se = (ctx) -> { + LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); + return ctx.search(base, filter, controls); + }; // Create a SearchExecutor to perform the search. if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } - search(searchExecutorWithLogging(base, filter, controls), handler); + search(se, handler); } /** @@ -266,12 +269,15 @@ public void search(final Name base, final String filter, final SearchControls co @Override public void search(final String base, final String filter, final SearchControls controls, NameClassPairCallbackHandler handler) { - + SearchExecutor se = (ctx) -> { + LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); + return ctx.search(base, filter, controls); + }; // Create a SearchExecutor to perform the search. if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } - search(searchExecutorWithLogging(base, filter, controls), handler); + search(se, handler); } /** @@ -280,12 +286,15 @@ public void search(final String base, final String filter, final SearchControls @Override public void search(final Name base, final String filter, final SearchControls controls, NameClassPairCallbackHandler handler, DirContextProcessor processor) { - + SearchExecutor se = (ctx) -> { + LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); + return ctx.search(base, filter, controls); + }; // Create a SearchExecutor to perform the search. if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } - search(searchExecutorWithLogging(base, filter, controls), handler, processor); + search(se, handler, processor); } /** @@ -294,12 +303,15 @@ public void search(final Name base, final String filter, final SearchControls co @Override public void search(final String base, final String filter, final SearchControls controls, NameClassPairCallbackHandler handler, DirContextProcessor processor) { - + SearchExecutor se = (ctx) -> { + LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); + return ctx.search(base, filter, controls); + }; // Create a SearchExecutor to perform the search. if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } - search(searchExecutorWithLogging(base, filter, controls), handler, processor); + search(se, handler, processor); } /** @@ -1552,7 +1564,10 @@ Stream searchForStream(LdapQuery query, Function mapper) assureReturnObjFlagSet(searchControls); - NamingEnumeration results = unchecked(searchSupplier(ctx, base, encodedFilter, searchControls)); + NamingEnumeration results = unchecked(() -> { + LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); + return ctx.search(base, encodedFilter, searchControls); + }); if (results == null) { return Stream.empty(); } @@ -1781,38 +1796,6 @@ public Stream findForStream(LdapQuery query, Class clazz) { return searchForStream(builder.filter(includeClass), contextMapper); } - private SearchExecutor searchExecutorWithLogging(final Name base, final String filter, - final SearchControls controls) { - return ctx -> { - if (LOG.isDebugEnabled()) { - LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); - } - return ctx.search(base, filter, controls); - }; - } - - private SearchExecutor searchExecutorWithLogging(final String base, final String filter, - final SearchControls controls) { - return ctx -> { - if (LOG.isDebugEnabled()) { - LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); - } - return ctx.search(base, filter, controls); - }; - } - - private CheckedSupplier> searchSupplier(final DirContext ctx, - final Name base, - final String filter, - final SearchControls controls) { - return () -> { - if (LOG.isDebugEnabled()) { - LOG.debug("Executing search with base [{}] and filter [{}]", base, filter); - } - return ctx.search(base, filter, controls); - }; - } - private T unchecked(CheckedSupplier supplier) { try { return supplier.get();