Skip to content

Commit a26975f

Browse files
Aditya Sekharrwinch
Aditya Sekhar
authored andcommitted
cleanup compatibility method based on #8868
1 parent 4602e9a commit a26975f

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

web/src/main/java/org/springframework/security/web/context/support/SecurityWebApplicationContextUtils.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.security.web.context.support;
1818

19-
import java.util.Enumeration;
20-
2119
import javax.servlet.ServletContext;
2220

2321
import org.springframework.util.Assert;
@@ -48,32 +46,11 @@ public abstract class SecurityWebApplicationContextUtils extends WebApplicationC
4846
* @see ServletContext#getAttributeNames()
4947
*/
5048
public static WebApplicationContext findRequiredWebApplicationContext(ServletContext servletContext) {
51-
WebApplicationContext webApplicationContext = compatiblyFindWebApplicationContext(servletContext);
49+
WebApplicationContext webApplicationContext = findWebApplicationContext(servletContext);
5250
Assert.state(webApplicationContext != null,
5351
"No WebApplicationContext found: no ContextLoaderListener registered?");
5452
return webApplicationContext;
5553
}
5654

57-
/**
58-
* Copy of {@link #findWebApplicationContext(ServletContext)} for compatibility with
59-
* spring framework 4.1.x.
60-
* @see #findWebApplicationContext(ServletContext)
61-
*/
62-
private static WebApplicationContext compatiblyFindWebApplicationContext(ServletContext sc) {
63-
WebApplicationContext webApplicationContext = getWebApplicationContext(sc);
64-
if (webApplicationContext == null) {
65-
Enumeration<String> attrNames = sc.getAttributeNames();
66-
while (attrNames.hasMoreElements()) {
67-
String attrName = attrNames.nextElement();
68-
Object attrValue = sc.getAttribute(attrName);
69-
if (attrValue instanceof WebApplicationContext) {
70-
Assert.state(webApplicationContext == null, "No unique WebApplicationContext found: more than one "
71-
+ "DispatcherServlet registered with publishContext=true?");
72-
webApplicationContext = (WebApplicationContext) attrValue;
73-
}
74-
}
75-
}
76-
return webApplicationContext;
77-
}
7855

7956
}

0 commit comments

Comments
 (0)