Skip to content

Commit 6a45574

Browse files
committed
ServletContextHandler.collectPropertyNames(HashSet, Object) is now typed
with generics
1 parent 6a0a1c1 commit 6a45574

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ The <action> type attribute can be add,update,fix,remove.
108108
<action dev="ggregory" type="fix" due-to="strangelookingnerd, Gary Gregory">Replace try-catch constructs in tests with assertThrows #215.</action>
109109
<action dev="ggregory" type="fix" due-to="Gary Gregory">Use generics internally.</action>
110110
<action dev="ggregory" type="fix" due-to="Gary Gregory">NodeSet.getPointers() is now typed with generics.</action>
111+
<action dev="ggregory" type="fix" due-to="Gary Gregory">ServletContextHandler.collectPropertyNames(HashSet, Object) is now typed with generics.</action>
111112
<!-- ADD -->
112113
<action issue="JXPATH-123" dev="mbenson" type="add">
113114
XPath function "ends-with" is not implemented (although "starts-with" is).

src/main/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
public class HttpSessionHandler extends ServletContextHandler {
3131

3232
@Override
33-
protected void collectPropertyNames(final HashSet set, final Object bean) {
33+
protected void collectPropertyNames(final HashSet<String> set, final Object bean) {
3434
final HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean;
3535
super.collectPropertyNames(set, handle.getServletContext());
3636
final HttpSession session = handle.getSession();
3737
if (session != null) {
38-
final Enumeration e = session.getAttributeNames();
38+
final Enumeration<String> e = session.getAttributeNames();
3939
while (e.hasMoreElements()) {
4040
set.add(e.nextElement());
4141
}

src/main/java/org/apache/commons/jxpath/servlet/ServletContextHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public class ServletContextHandler implements DynamicPropertyHandler {
3737
* @param set destination
3838
* @param bean to read
3939
*/
40-
protected void collectPropertyNames(final HashSet set, Object bean) {
40+
protected void collectPropertyNames(final HashSet<String> set, Object bean) {
4141
if (bean instanceof HttpSessionAndServletContext) {
4242
bean = ((HttpSessionAndServletContext) bean).getServletContext();
4343
}
44-
final Enumeration e = ((ServletContext) bean).getAttributeNames();
44+
final Enumeration<String> e = ((ServletContext) bean).getAttributeNames();
4545
while (e.hasMoreElements()) {
4646
set.add(e.nextElement());
4747
}
@@ -54,9 +54,9 @@ public Object getProperty(final Object context, final String property) {
5454

5555
@Override
5656
public String[] getPropertyNames(final Object context) {
57-
final HashSet list = new HashSet(DEFAULT_PROPERTY_COUNT);
58-
collectPropertyNames(list, context);
59-
return (String[]) list.toArray(new String[list.size()]);
57+
final HashSet<String> set = new HashSet<>(DEFAULT_PROPERTY_COUNT);
58+
collectPropertyNames(set, context);
59+
return (String[]) set.toArray(new String[set.size()]);
6060
}
6161

6262
@Override

src/main/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
public class ServletRequestHandler extends HttpSessionHandler {
3030

3131
@Override
32-
protected void collectPropertyNames(final HashSet set, final Object bean) {
32+
protected void collectPropertyNames(final HashSet<String> set, final Object bean) {
3333
super.collectPropertyNames(set, bean);
3434
final ServletRequestAndContext handle = (ServletRequestAndContext) bean;
3535
final ServletRequest servletRequest = handle.getServletRequest();
36-
Enumeration e = servletRequest.getAttributeNames();
36+
Enumeration<String> e = servletRequest.getAttributeNames();
3737
while (e.hasMoreElements()) {
3838
set.add(e.nextElement());
3939
}

0 commit comments

Comments
 (0)