Author: areshetnyak
Date: 2011-01-13 07:19:54 -0500 (Thu, 13 Jan 2011)
New Revision: 3805
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java
Log:
EXOJCR-1118 : The problem with thread safe in IncrementalBackupJob was fixed.
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/fs/IncrementalBackupJob.java 2011-01-13
10:43:01 UTC (rev 3804)
+++
jcr/trunk/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)
@@ -124,59 +124,62 @@
}
}
- public synchronized void writeExternal(ObjectOutputStream out, TransactionChangesLog
changesLog,
+ public void writeExternal(ObjectOutputStream out, TransactionChangesLog changesLog,
FileCleaner fileCleaner)
throws IOException
{
PendingChangesLog pendingChangesLog = new PendingChangesLog(changesLog,
fileCleaner);
- if (pendingChangesLog.getConteinerType() ==
PendingChangesLog.Type.CHANGESLOG_WITH_STREAM)
+ synchronized (out)
{
+ if (pendingChangesLog.getConteinerType() ==
PendingChangesLog.Type.CHANGESLOG_WITH_STREAM)
+ {
- out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITH_STREAM);
- out.writeObject(changesLog);
+ out.writeInt(PendingChangesLog.Type.CHANGESLOG_WITH_STREAM);
+ out.writeObject(changesLog);
- // Write FixupStream
- List<FixupStream> listfs = pendingChangesLog.getFixupStreams();
- out.writeInt(listfs.size());
+ // Write FixupStream
+ List<FixupStream> listfs = pendingChangesLog.getFixupStreams();
+ out.writeInt(listfs.size());
- for (int i = 0; i < listfs.size(); i++)
- {
- listfs.get(i).writeExternal(out);
- }
+ for (int i = 0; i < listfs.size(); i++)
+ {
+ listfs.get(i).writeExternal(out);
+ }
- // write stream data
- List<InputStream> listInputList = pendingChangesLog.getInputStreams();
+ // write stream data
+ List<InputStream> listInputList = pendingChangesLog.getInputStreams();
- // write file count
- out.writeInt(listInputList.size());
+ // write file count
+ out.writeInt(listInputList.size());
- for (int i = 0; i < listInputList.size(); i++)
- {
- File tempFile = getAsFile(listInputList.get(i));
- FileInputStream fis = PrivilegedFileHelper.fileInputStream(tempFile);
+ for (int i = 0; i < listInputList.size(); i++)
+ {
+ File tempFile = getAsFile(listInputList.get(i));
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(tempFile);
- // write file size
- out.writeLong(PrivilegedFileHelper.length(tempFile));
+ // write file size
+ out.writeLong(PrivilegedFileHelper.length(tempFile));
- // write file content
- writeContent(fis, out);
+ // write file content
+ writeContent(fis, out);
- fis.close();
- fileCleaner.addFile(tempFile);
+ fis.close();
+ fileCleaner.addFile(tempFile);
+ }
+
+ // restore changes log worlds
+
}
+ else
+ {
+ 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