This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git
commit 6a45574ec23c17523eb42d124d14b7abfcb8b2de Author: Gary D. Gregory <[email protected]> AuthorDate: Sun Mar 16 16:29:44 2025 -0400 ServletContextHandler.collectPropertyNames(HashSet, Object) is now typed with generics --- src/changes/changes.xml | 1 + .../org/apache/commons/jxpath/servlet/HttpSessionHandler.java | 4 ++-- .../apache/commons/jxpath/servlet/ServletContextHandler.java | 10 +++++----- .../apache/commons/jxpath/servlet/ServletRequestHandler.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6da44d1..5b8b3f5 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -108,6 +108,7 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ggregory" type="fix" due-to="strangelookingnerd, Gary Gregory">Replace try-catch constructs in tests with assertThrows #215.</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">Use generics internally.</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">NodeSet.getPointers() is now typed with generics.</action> + <action dev="ggregory" type="fix" due-to="Gary Gregory">ServletContextHandler.collectPropertyNames(HashSet, Object) is now typed with generics.</action> <!-- ADD --> <action issue="JXPATH-123" dev="mbenson" type="add"> XPath function "ends-with" is not implemented (although "starts-with" is). diff --git a/src/main/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java b/src/main/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java index ce85323..ab33ee8 100644 --- a/src/main/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java +++ b/src/main/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java @@ -30,12 +30,12 @@ import org.apache.commons.jxpath.JXPathException; public class HttpSessionHandler extends ServletContextHandler { @Override - protected void collectPropertyNames(final HashSet set, final Object bean) { + protected void collectPropertyNames(final HashSet<String> set, final Object bean) { final HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean; super.collectPropertyNames(set, handle.getServletContext()); final HttpSession session = handle.getSession(); if (session != null) { - final Enumeration e = session.getAttributeNames(); + final Enumeration<String> e = session.getAttributeNames(); while (e.hasMoreElements()) { set.add(e.nextElement()); } diff --git a/src/main/java/org/apache/commons/jxpath/servlet/ServletContextHandler.java b/src/main/java/org/apache/commons/jxpath/servlet/ServletContextHandler.java index 1969f45..b233ebf 100644 --- a/src/main/java/org/apache/commons/jxpath/servlet/ServletContextHandler.java +++ b/src/main/java/org/apache/commons/jxpath/servlet/ServletContextHandler.java @@ -37,11 +37,11 @@ public class ServletContextHandler implements DynamicPropertyHandler { * @param set destination * @param bean to read */ - protected void collectPropertyNames(final HashSet set, Object bean) { + protected void collectPropertyNames(final HashSet<String> set, Object bean) { if (bean instanceof HttpSessionAndServletContext) { bean = ((HttpSessionAndServletContext) bean).getServletContext(); } - final Enumeration e = ((ServletContext) bean).getAttributeNames(); + final Enumeration<String> e = ((ServletContext) bean).getAttributeNames(); while (e.hasMoreElements()) { set.add(e.nextElement()); } @@ -54,9 +54,9 @@ public class ServletContextHandler implements DynamicPropertyHandler { @Override public String[] getPropertyNames(final Object context) { - final HashSet list = new HashSet(DEFAULT_PROPERTY_COUNT); - collectPropertyNames(list, context); - return (String[]) list.toArray(new String[list.size()]); + final HashSet<String> set = new HashSet<>(DEFAULT_PROPERTY_COUNT); + collectPropertyNames(set, context); + return (String[]) set.toArray(new String[set.size()]); } @Override diff --git a/src/main/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java b/src/main/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java index 5a44910..a8f31d1 100644 --- a/src/main/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java +++ b/src/main/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java @@ -29,11 +29,11 @@ import javax.servlet.ServletRequest; public class ServletRequestHandler extends HttpSessionHandler { @Override - protected void collectPropertyNames(final HashSet set, final Object bean) { + protected void collectPropertyNames(final HashSet<String> set, final Object bean) { super.collectPropertyNames(set, bean); final ServletRequestAndContext handle = (ServletRequestAndContext) bean; final ServletRequest servletRequest = handle.getServletRequest(); - Enumeration e = servletRequest.getAttributeNames(); + Enumeration<String> e = servletRequest.getAttributeNames(); while (e.hasMoreElements()) { set.add(e.nextElement()); }
