import java.util.LinkedList;
import java.util.Locale;
import java.util.Properties;
-import java.util.Random;
import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.ApplicationResource;
Terminal.ErrorListener, Serializable {
/**
- * Random window name generator.
+ * Id use for the next window that is opened. Access to this must be
+ * synchronized.
*/
- private static Random nameGenerator = new Random();
+ private int nextWindowId = 1;
/**
* Application context the application is running in.
while (!accepted) {
// Try another name
- name = String.valueOf(Math.abs(nameGenerator.nextInt()));
+ synchronized (this) {
+ name = String.valueOf(nextWindowId);
+ nextWindowId++;
+ }
+
if (!windows.containsKey(name)) {
accepted = true;
}
private DragAndDropService dragAndDropService;
+ private static int nextUnusedWindowSuffix = 1;
+
/**
* TODO New constructor - document me!
*
// If the requested window is already open, resolve conflict
if (currentlyOpenWindowsInClient.containsKey(window.getName())) {
String newWindowName = window.getName();
- while (currentlyOpenWindowsInClient.containsKey(newWindowName)) {
- newWindowName = window.getName() + "_"
- + ((int) (Math.random() * 100000000));
+
+ synchronized (AbstractCommunicationManager.class) {
+ while (currentlyOpenWindowsInClient.containsKey(newWindowName)) {
+ newWindowName = window.getName() + "_"
+ + nextUnusedWindowSuffix++;
+ }
}
window = application.getWindow(newWindowName);