You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by "Bono, Chris" <Bo...@zilliant.com> on 2001/05/09 20:36:20 UTC

ServerHTTPUtils bug???

I noticed that when I did not have a DeployedServices.ds file (before any services were deployed) that
ServerHTTPUtils.getFileFromNameAndContext would throw a NullPointerException.
The reason was that it would call ServletContext.getRealPath(fileName) where fileName does not exist and therfore is
null. The null result would then be passed into File.<init>. It seems to me that the default null check should be made
and then just assume under the current directory.

OLD CODE:
================
ServerHTTPUtils


  public static File getFileFromNameAndContext(String fileName,
                                               ServletContext context) {
    File file = new File(fileName);
    return (file.isAbsolute()
            ? file
            : new File(context.getRealPath(fileName))); // this dies if file does not already exist    
  }


NEW CODE:
================
ServerHTTPUtils


  public static File getFileFromNameAndContext(String fileName,
                                               ServletContext context) {
    File file = new File(fileName);
    if (!file.isAbsolute) {
	 String realPath = context.getRealPath(fileName);
       if (realPath != null) {
	     file = new File(realPath);
       }
    }
    return file;
  }


Chris Bono
bonoc@zilliant.com
512.531.8518
http://www.zilliant.com
 

---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org