[jbosscache-commits] JBoss Cache SVN: r5452 - amazon-s3/trunk/src/main/java/com/amazon/s3/emulator.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Mar 19 20:05:23 EDT 2008


Author: genman
Date: 2008-03-19 20:05:23 -0400 (Wed, 19 Mar 2008)
New Revision: 5452

Modified:
   amazon-s3/trunk/src/main/java/com/amazon/s3/emulator/Server.java
Log:
Javadoc
Fix potential thread safety issues

Modified: amazon-s3/trunk/src/main/java/com/amazon/s3/emulator/Server.java
===================================================================
--- amazon-s3/trunk/src/main/java/com/amazon/s3/emulator/Server.java	2008-03-20 00:00:45 UTC (rev 5451)
+++ amazon-s3/trunk/src/main/java/com/amazon/s3/emulator/Server.java	2008-03-20 00:05:23 UTC (rev 5452)
@@ -30,6 +30,16 @@
 import com.amazon.s3.Owner;
 import com.amazon.s3.S3Object;
 
+/**
+ * Amazon S3 emulator that stores data in an internal sorted map.
+ * Not highly scalable or reliable, but may be fine for testing your application.
+ * 
+ * Some browse methods are not complete.
+ * Get Data/Put/Head are mostly complete.
+ * What's supported is in the test suite.
+ * 
+ * @author Elias Ross
+ */
 public class Server extends HttpServlet {
 
 	private static final long serialVersionUID = 1L;
@@ -37,7 +47,7 @@
 	private Log log = LogFactory.getLog(getClass());
 	private ServletServer ss;
 	private boolean bucket = false;
-	private SortedMap<Entry, S3Object> map = new TreeMap<Entry, S3Object>();
+	private SortedMap<Entry, S3Object> map = Collections.synchronizedSortedMap(new TreeMap<Entry, S3Object>());
 
 	public Server() throws IOException {
 		ss = new ServletServer(this);
@@ -125,9 +135,9 @@
 		if (maxKeysStr != null)
 			maxKeys = Integer.parseInt(maxKeysStr);
 		Writer w = new Writer();
-		Map<Entry, S3Object> submap = map;
+		SortedMap<Entry, S3Object> submap = new TreeMap<Entry, S3Object>(map);
 		if (prefix != null)
-			submap = map.tailMap(new Entry(prefix));
+			submap = submap.tailMap(new Entry(prefix));
 		int keyCount = 0;
 		boolean truncated = false;
 		String nextMarker = null;




More information about the jbosscache-commits mailing list