From 3308b2034cb03da4feb4584f609ad58bd5c021b3 Mon Sep 17 00:00:00 2001 From: Abhishek Pai Date: Tue, 12 Nov 2024 11:15:18 +0100 Subject: [PATCH] #176: Improving contextRequestControls --- src/main/java/org/lsc/jndi/JndiServices.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/lsc/jndi/JndiServices.java b/src/main/java/org/lsc/jndi/JndiServices.java index c8f94e86..110f8304 100644 --- a/src/main/java/org/lsc/jndi/JndiServices.java +++ b/src/main/java/org/lsc/jndi/JndiServices.java @@ -1205,23 +1205,20 @@ public byte[] pagination() throws IOException, NamingException { * Applying request controls such as pageSize and sortedBy for LDAP Context. */ public void contextRequestControls() { + List requestControls = new ArrayList<>(); try { // Setting global pageSize variable String pageSizeStr = (String) ctx.getEnvironment().get("java.naming.ldap.pageSize"); if (pageSizeStr != null && Integer.parseInt(pageSizeStr) > -1) { pageSize = Integer.parseInt(pageSizeStr); - List requestControls = new ArrayList<>(); requestControls.add(new PagedResultsControl(pageSize, Control.CRITICAL)); - ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } - // Setting global sortedBy variable sortedBy = (String) ctx.getEnvironment().get("java.naming.ldap.sortedBy"); if (sortedBy != null) { - List requestControls = new ArrayList<>(); requestControls.add(new SortControl(sortedBy, Control.CRITICAL)); - ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } + ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } catch (NamingException | IOException e) { throw new RuntimeException(e); }