Author: areshetnyak
Date: 2011-01-13 08:17:04 -0500 (Thu, 13 Jan 2011)
New Revision: 3806
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java
Log:
JCR-1574 : The problem with thread safe in IncrementalBackupJob was fixed.
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java 2011-01-13
12:19:54 UTC (rev 3805)
+++
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java 2011-01-13
13:17:04 UTC (rev 3806)
@@ -130,52 +130,55 @@
PendingChangesLog pendingChangesLog = new PendingChangesLog(changesLog,
fileCleaner);
- if (pendingChangesLog.getConteinerType() ==
PendingChangesLog.Type.CHANGESLOG_WITH_STREAM)
+ synchronized (out)
{
-
- out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITH_STREAM);
- out.writeObject(changesLog);
-
- // Write FixupStream
- List<FixupStream> listfs = pendingChangesLog.getFixupStreams();
- out.writeInt(listfs.size());
-
- for (int i = 0; i < listfs.size(); i++)
+ if (pendingChangesLog.getConteinerType() ==
PendingChangesLog.Type.CHANGESLOG_WITH_STREAM)
{
- listfs.get(i).writeExternal(out);
+
+ out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITH_STREAM);
+ out.writeObject(changesLog);
+
+ // Write FixupStream
+ List<FixupStream> listfs = pendingChangesLog.getFixupStreams();
+ out.writeInt(listfs.size());
+
+ for (int i = 0; i < listfs.size(); i++)
+ {
+ listfs.get(i).writeExternal(out);
+ }
+
+ // write stream data
+ List<InputStream> listInputList = pendingChangesLog.getInputStreams();
+
+ // write file count
+ out.writeInt(listInputList.size());
+
+ for (int i = 0; i < listInputList.size(); i++)
+ {
+ File tempFile = getAsFile(listInputList.get(i));
+ FileInputStream fis = new FileInputStream(tempFile);
+
+ // write file size
+ out.writeLong(tempFile.length());
+
+ // write file content
+ writeContent(fis, out);
+
+ fis.close();
+ fileCleaner.addFile(tempFile);
+ }
+
+ // restore changes log worlds
+
}
-
- // write stream data
- List<InputStream> listInputList = pendingChangesLog.getInputStreams();
-
- // write file count
- out.writeInt(listInputList.size());
-
- for (int i = 0; i < listInputList.size(); i++)
+ else
{
- File tempFile = getAsFile(listInputList.get(i));
- FileInputStream fis = new FileInputStream(tempFile);
-
- // write file size
- out.writeLong(tempFile.length());
-
- // write file content
- writeContent(fis, out);
-
- fis.close();
- fileCleaner.addFile(tempFile);
+ out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITHOUT_STREAM);
+ out.writeObject(changesLog);
}
-
- // restore changes log worlds
-
+
+ out.flush();
}
- else
- {
- out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITHOUT_STREAM);
- out.writeObject(changesLog);
- }
-
- out.flush();
}
private File getAsFile(InputStream is) throws IOException