You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2007/08/29 19:47:04 UTC

svn commit: r570877 - /wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java

Author: ivaynberg
Date: Wed Aug 29 10:47:03 2007
New Revision: 570877

URL: http://svn.apache.org/viewvc?rev=570877&view=rev
Log:
apparently getting last modified date on a resource in jar fails, this leads to the log being flooded with the error messages because modification task runs once a second by default. so first we check if the error is for a resource inside a jar and log it with debug if it is

Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java?rev=570877&r1=570876&r2=570877&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java Wed Aug 29 10:47:03 2007
@@ -39,7 +39,9 @@
  * @see org.apache.wicket.util.watch.IModifiable
  * @author Jonathan Locke
  */
-public class UrlResourceStream extends AbstractResourceStream implements IFixedLocationResourceStream
+public class UrlResourceStream extends AbstractResourceStream
+		implements
+			IFixedLocationResourceStream
 {
 	private static final long serialVersionUID = 1L;
 
@@ -89,8 +91,8 @@
 			}
 			catch (Exception ex)
 			{
-				log.debug("cannot convert url: " + url + " to file (" + ex.getMessage()
-						+ "), falling back to the inputstream for polling");
+				log.debug("cannot convert url: " + url + " to file (" + ex.getMessage() +
+						"), falling back to the inputstream for polling");
 			}
 			if (file != null && !file.exists())
 			{
@@ -146,8 +148,7 @@
 	}
 
 	/**
-	 * @return The content type of this resource, such as "image/jpeg" or
-	 *         "text/html"
+	 * @return The content type of this resource, such as "image/jpeg" or "text/html"
 	 */
 	public String getContentType()
 	{
@@ -156,8 +157,8 @@
 	}
 
 	/**
-	 * Method to test the content type on null or unknown. if this is the case
-	 * the content type is tried to be resolved throw the servlet context
+	 * Method to test the content type on null or unknown. if this is the case the content type is
+	 * tried to be resolved throw the servlet context
 	 */
 	private void testContentType()
 	{
@@ -168,8 +169,8 @@
 			{
 				// TODO Post 1.2: General: For non webapplication another method
 				// should be implemented (getMimeType on application?)
-				contentType = ((WebApplication)application).getServletContext()
-						.getMimeType(url.getFile());
+				contentType = ((WebApplication)application).getServletContext().getMimeType(
+						url.getFile());
 				if (contentType == null)
 				{
 					contentType = URLConnection.getFileNameMap().getContentTypeFor(url.getFile());
@@ -196,8 +197,8 @@
 			}
 			catch (IOException e)
 			{
-				throw new ResourceStreamNotFoundException("Resource " + url
-						+ " could not be opened", e);
+				throw new ResourceStreamNotFoundException("Resource " + url +
+						" could not be opened", e);
 			}
 		}
 
@@ -224,7 +225,7 @@
 			if (lastModified != this.lastModified)
 			{
 				this.lastModified = lastModified;
-				this.contentLength = (int)file.length();
+				contentLength = (int)file.length();
 			}
 		}
 		else
@@ -259,12 +260,22 @@
 				{
 					this.lastModified = lastModified;
 					close = true;
-					this.contentLength = urlConnection.getContentLength();
+					contentLength = urlConnection.getContentLength();
 				}
 			}
 			catch (IOException e)
 			{
-				log.error("getLastModified for " + url + " failed: " + e.getMessage());
+				if (url.toString().contains(".jar!"))
+				{
+					if (log.isDebugEnabled())
+					{
+						log.debug("getLastModified for " + url + " failed: " + e.getMessage());
+					}
+				}
+				else
+				{
+					log.error("getLastModified for " + url + " failed: " + e.getMessage());
+				}
 			}
 			finally
 			{