You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by jh...@apache.org on 2002/06/23 06:15:21 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/upload DiskMultipartRequestHandler.java
jholmes 2002/06/22 21:15:21
Modified: src/share/org/apache/struts/upload
DiskMultipartRequestHandler.java
Log:
update the retrieveTempDir() method to insure that
NullPointerExceptions won't be thrown if the call to
getServlet() returns null
PR: Bugzilla #9117
Revision Changes Path
1.16 +13 -9 jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java
Index: DiskMultipartRequestHandler.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DiskMultipartRequestHandler.java 22 Mar 2002 23:47:18 -0000 1.15
+++ DiskMultipartRequestHandler.java 23 Jun 2002 04:15:21 -0000 1.16
@@ -229,16 +229,20 @@
protected void retrieveTempDir(ApplicationConfig appConfig) {
//attempt to retrieve the servlet container's temporary directory
- ServletContext context = getServlet().getServletContext();
-
- try {
- tempDir =
- (String) context.getAttribute("javax.servlet.context.tempdir");
- }
- catch (ClassCastException cce) {
- tempDir = ((File) context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
+ ActionServlet servlet = getServlet();
+ if (servlet != null) {
+ //attempt to retrieve the servlet container's temporary directory
+ ServletContext context = servlet.getServletContext();
+
+ try {
+ tempDir =
+ (String) context.getAttribute("javax.servlet.context.tempdir");
+ }
+ catch (ClassCastException cce) {
+ tempDir = ((File) context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
+ }
}
-
+
if (tempDir == null) {
//attempt to retrieve the temporary directory from the controller
tempDir = appConfig.getControllerConfig().getTempDir();
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>