Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
448f5b86
Commit
448f5b86
authored
Sep 16, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify error page config by dropping redundant support for Tomcat 7
Closes gh-17937
parent
84b2438c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
89 deletions
+5
-89
TomcatErrorPage.java
...ngframework/boot/web/embedded/tomcat/TomcatErrorPage.java
+0
-88
TomcatServletWebServerFactory.java
...ot/web/embedded/tomcat/TomcatServletWebServerFactory.java
+5
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java
deleted
100644 → 0
View file @
84b2438c
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
embedded
.
tomcat
;
import
java.lang.reflect.Method
;
import
org.apache.catalina.Context
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.boot.web.server.ErrorPage
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
/**
* Tomcat specific management for an {@link ErrorPage}.
*
* @author Dave Syer
* @author Phillip Webb
*/
class
TomcatErrorPage
{
private
static
final
String
ERROR_PAGE_CLASS
=
"org.apache.tomcat.util.descriptor.web.ErrorPage"
;
private
final
String
location
;
private
final
String
exceptionType
;
private
final
int
errorCode
;
private
final
Object
nativePage
;
TomcatErrorPage
(
ErrorPage
errorPage
)
{
this
.
location
=
errorPage
.
getPath
();
this
.
exceptionType
=
errorPage
.
getExceptionName
();
this
.
errorCode
=
errorPage
.
getStatusCode
();
this
.
nativePage
=
createNativePage
();
}
private
Object
createNativePage
()
{
try
{
if
(
ClassUtils
.
isPresent
(
ERROR_PAGE_CLASS
,
null
))
{
return
BeanUtils
.
instantiateClass
(
ClassUtils
.
forName
(
ERROR_PAGE_CLASS
,
null
));
}
}
catch
(
ClassNotFoundException
|
LinkageError
ex
)
{
// Swallow and continue
}
return
null
;
}
void
addToContext
(
Context
context
)
{
Assert
.
state
(
this
.
nativePage
!=
null
,
"No Tomcat 8 detected so no native error page exists"
);
if
(
ClassUtils
.
isPresent
(
ERROR_PAGE_CLASS
,
null
))
{
org
.
apache
.
tomcat
.
util
.
descriptor
.
web
.
ErrorPage
errorPage
=
(
org
.
apache
.
tomcat
.
util
.
descriptor
.
web
.
ErrorPage
)
this
.
nativePage
;
errorPage
.
setLocation
(
this
.
location
);
errorPage
.
setErrorCode
(
this
.
errorCode
);
errorPage
.
setExceptionType
(
this
.
exceptionType
);
context
.
addErrorPage
(
errorPage
);
}
else
{
callMethod
(
this
.
nativePage
,
"setLocation"
,
this
.
location
,
String
.
class
);
callMethod
(
this
.
nativePage
,
"setErrorCode"
,
this
.
errorCode
,
int
.
class
);
callMethod
(
this
.
nativePage
,
"setExceptionType"
,
this
.
exceptionType
,
String
.
class
);
callMethod
(
context
,
"addErrorPage"
,
this
.
nativePage
,
this
.
nativePage
.
getClass
());
}
}
private
void
callMethod
(
Object
target
,
String
name
,
Object
value
,
Class
<?>
type
)
{
Method
method
=
ReflectionUtils
.
findMethod
(
target
.
getClass
(),
name
,
type
);
ReflectionUtils
.
invokeMethod
(
method
,
target
,
value
);
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java
View file @
448f5b86
...
@@ -362,7 +362,11 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
...
@@ -362,7 +362,11 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
context
.
getPipeline
().
addValve
(
valve
);
context
.
getPipeline
().
addValve
(
valve
);
}
}
for
(
ErrorPage
errorPage
:
getErrorPages
())
{
for
(
ErrorPage
errorPage
:
getErrorPages
())
{
new
TomcatErrorPage
(
errorPage
).
addToContext
(
context
);
org
.
apache
.
tomcat
.
util
.
descriptor
.
web
.
ErrorPage
tomcatErrorPage
=
new
org
.
apache
.
tomcat
.
util
.
descriptor
.
web
.
ErrorPage
();
tomcatErrorPage
.
setLocation
(
errorPage
.
getPath
());
tomcatErrorPage
.
setErrorCode
(
errorPage
.
getStatusCode
());
tomcatErrorPage
.
setExceptionType
(
errorPage
.
getExceptionName
());
context
.
addErrorPage
(
tomcatErrorPage
);
}
}
for
(
MimeMappings
.
Mapping
mapping
:
getMimeMappings
())
{
for
(
MimeMappings
.
Mapping
mapping
:
getMimeMappings
())
{
context
.
addMimeMapping
(
mapping
.
getExtension
(),
mapping
.
getMimeType
());
context
.
addMimeMapping
(
mapping
.
getExtension
(),
mapping
.
getMimeType
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment