You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ja...@apache.org on 2008/06/13 23:21:23 UTC

svn commit: r667659 - /wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java

Author: janne
Date: Fri Jun 13 14:21:22 2008
New Revision: 667659

URL: http://svn.apache.org/viewvc?rev=667659&view=rev
Log:
fix for WICKET-1701 - allow serialization of CachedPackageResource

Modified:
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java?rev=667659&r1=667658&r2=667659&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java Fri Jun 13 14:21:22 2008
@@ -54,7 +54,7 @@
 		private static final long serialVersionUID = 1L;
 
 		/** Cache for compressed data */
-		private SoftReference cache = new SoftReference(null);
+		private transient SoftReference cache = new SoftReference(null);
 
 		/** Timestamp of the cache */
 		private Time timeStamp = null;
@@ -136,15 +136,18 @@
 			IResourceStream stream = getOriginalResourceStream();
 			try
 			{
-				byte ret[] = (byte[])cache.get();
-				if (ret != null && timeStamp != null)
+				byte ret[];
+				if (cache != null)
 				{
-					if (timeStamp.equals(stream.lastModifiedTime()))
+					ret = (byte[])cache.get();
+					if (ret != null && timeStamp != null)
 					{
-						return ret;
+						if (timeStamp.equals(stream.lastModifiedTime()))
+						{
+							return ret;
+						}
 					}
 				}
-
 				ByteArrayOutputStream out = new ByteArrayOutputStream();
 				GZIPOutputStream zout = new GZIPOutputStream(out);
 				Streams.copy(stream.getInputStream(), zout);
@@ -186,16 +189,16 @@
 	 *            The style of the resource (see {@link org.apache.wicket.Session})
 	 * @return The resource
 	 * @throws PackageResourceBlockedException
-	 *             when the target resource is not accepted by
-	 *             {@link IPackageResourceGuard the package resource guard}.
+	 *             when the target resource is not accepted by {@link IPackageResourceGuard the
+	 *             package resource guard}.
 	 */
 	public static PackageResource get(final Class scope, final String path, final Locale locale,
-			final String style)
+		final String style)
 	{
 		final SharedResources sharedResources = Application.get().getSharedResources();
 
 		PackageResource resource = (PackageResource)sharedResources.get(scope, path, locale, style,
-				true);
+			true);
 		if (resource == null)
 		{
 			resource = new CompressedPackageResource(scope, path, locale, style);