[Schmitzm-commits] r1517 - branches/2.3.x/src/schmitzm/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 18 00:28:01 CET 2011
Author: alfonx
Date: 2011-03-18 00:28:00 +0100 (Fri, 18 Mar 2011)
New Revision: 1517
Modified:
branches/2.3.x/src/schmitzm/io/IOUtil.java
Log:
Avoiding an excesiv errormessage in log when trying to download a cached JNLP resource, by making getFilename more error-prone.
/**
* @return the "Filename" of an {@link URL}. e.g.
* <code>http://www.bahn.de/exterme/index.html?k=v</code> returns
* <code>index.html</code><br/>
* <code>http://www.bahn.de/exterme/</code> and
* <code>http://www.bahn.de/exterme<code> both return <code>exterme</code>
* Any Exception will return "";
*/
public static String getFilename(URL url) {
try {
return new File(url.getPath()).getName();
} catch (Exception e) {
LOGGER.debug("Failed to get Filename for URL '" + url
+ "'. Returning an empty string.", e);
return "";
}
}
Modified: branches/2.3.x/src/schmitzm/io/IOUtil.java
===================================================================
--- branches/2.3.x/src/schmitzm/io/IOUtil.java 2011-03-17 22:58:11 UTC (rev 1516)
+++ branches/2.3.x/src/schmitzm/io/IOUtil.java 2011-03-17 23:28:00 UTC (rev 1517)
@@ -1173,10 +1173,17 @@
* <code>index.html</code><br/>
* <code>http://www.bahn.de/exterme/</code> and
* <code>http://www.bahn.de/exterme<code> both return <code>exterme</code>
+ * Any Exception will return "";
*/
public static String getFilename(URL url) {
- if (url == null) return "";
- return new File(url.getPath()).getName();
+ try {
+ return new File(url.getPath()).getName();
+ } catch (Exception e) {
+ LOGGER.debug("Failed to get Filename for URL '" + url
+ + "'. Returning an empty string.", e);
+ return "";
+ }
}
+
}
More information about the Schmitzm-commits
mailing list