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:13:59 UTC

svn commit: r667655 - /wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java

Author: janne
Date: Fri Jun 13 14:13:58 2008
New Revision: 667655

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

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java?rev=667655&r1=667654&r2=667655&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CompressedPackageResource.java Fri Jun 13 14:13:58 2008
@@ -58,7 +58,7 @@
 		private static final long serialVersionUID = 1L;
 
 		/** Cache for compressed data */
-		private SoftReference<byte[]> cache = new SoftReference<byte[]>(null);
+		private transient SoftReference<byte[]> cache = new SoftReference<byte[]>(null);
 
 		/** Timestamp of the cache */
 		private Time timeStamp = null;
@@ -140,15 +140,18 @@
 			IResourceStream stream = getOriginalResourceStream();
 			try
 			{
-				byte ret[] = cache.get();
-				if (ret != null && timeStamp != null)
+				byte ret[];
+				if (cache != null)
 				{
-					if (timeStamp.equals(stream.lastModifiedTime()))
+					ret = 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);
@@ -188,11 +191,11 @@
 	 *            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)
+	public static PackageResource get(final Class<?> scope, final String path, final Locale locale,
+		final String style)
 	{
 		final SharedResources sharedResources = Application.get().getSharedResources();
 
@@ -219,7 +222,7 @@
 	 * @param style
 	 *            The style of the resource
 	 */
-	protected CompressedPackageResource(Class< ? > scope, String path, Locale locale, String style)
+	protected CompressedPackageResource(Class<?> scope, String path, Locale locale, String style)
 	{
 		super(scope, path, locale, style);
 		resourceStream = newResourceStream();