[vlma-devel] commit: Make loadFromDisk do what anybody would expect it to do. ( Adrien Grand )
git version control
git at videolan.org
Thu Aug 14 00:16:11 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Aug 12 21:58:19 2008 +0200| [d44f02cf714c2974008e8658024c6b4e9c1d9ff8] | committer: Adrien Grand
Make loadFromDisk do what anybody would expect it to do.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=d44f02cf714c2974008e8658024c6b4e9c1d9ff8
---
.../java/org/videolan/vlma/dao/VLMaDaoImpl.java | 26 +++++++++++++------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java b/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
index 86a859e..5493cd6 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
@@ -299,24 +299,34 @@ public class VLMaDaoImpl implements VLMaDao {
synchronized public void loadFromDisk() {
String vlmaData = configuration.getString("vlma.data");
try {
- FileInputStream f = new FileInputStream(new File(vlmaData, DATA_FILE));
+ File dataFile = new File(vlmaData, DATA_FILE);
+ FileInputStream f = new FileInputStream(dataFile);
List<List> loadList;
loadList = (List<List>) xstream.fromXML(f);
try {
f.close();
} catch (IOException e) {
- logger.error("Error closing data.xml", e);
+ logger.error("Error closing " + dataFile, e);
}
- for (Satellite satellite : (List<Satellite>) loadList.get(0)) {
- satellites.put(satellite.getId(), satellite);
+ synchronized (satellites) {
+ satellites = new HashMap<Integer, Satellite>();
+ for (Satellite satellite : (List<Satellite>) loadList.get(0)) {
+ satellites.put(satellite.getId(), satellite);
+ }
}
- for (Server server : (List<Server>) loadList.get(1)) {
- servers.put(server.getId(), server);
+ synchronized (servers) {
+ servers = new HashMap<Integer, Server>();
+ for (Server server : (List<Server>) loadList.get(1)) {
+ servers.put(server.getId(), server);
+ }
}
- for (Media media : (List<Media>) loadList.get(2)) {
- medias.put(media.getId(), media);
+ synchronized (medias) {
+ medias = new HashMap<Integer, Media>();
+ for (Media media : (List<Media>) loadList.get(2)) {
+ medias.put(media.getId(), media);
+ }
}
}
catch (FileNotFoundException e) {
More information about the vlma-devel
mailing list