From commits-return-6604-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Mon Nov 17 10:40:44 2008 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 50258 invoked from network); 17 Nov 2008 10:40:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Nov 2008 10:40:43 -0000 Received: (qmail 55736 invoked by uid 500); 17 Nov 2008 10:40:47 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 55645 invoked by uid 500); 17 Nov 2008 10:40:47 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 55619 invoked by uid 99); 17 Nov 2008 10:40:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2008 02:40:47 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2008 10:39:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5600F238887D; Mon, 17 Nov 2008 02:39:48 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r718216 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java Date: Mon, 17 Nov 2008 10:39:47 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081117103948.5600F238887D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Mon Nov 17 02:39:45 2008 New Revision: 718216 URL: http://svn.apache.org/viewvc?rev=718216&view=rev Log: 1.5: Merged revision 713072 (JCR-1850). Ignored revisions 713059, 713065, 713076 and 713162. Modified: jackrabbit/branches/1.5/ (props changed) jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java Propchange: jackrabbit/branches/1.5/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Nov 17 02:39:45 2008 @@ -1,2 +1,2 @@ /jackrabbit/branches/1.3:631261 -/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037 +/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162 Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java?rev=718216&r1=718215&r2=718216&view=diff ============================================================================== --- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java (original) +++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java Mon Nov 17 02:39:45 2008 @@ -31,6 +31,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; /** * A file record log is a file containing {@link Record}s. Every file record @@ -140,7 +142,8 @@ this.logFile = logFile; if (logFile.exists()) { - DataInputStream in = new DataInputStream(new FileInputStream(logFile)); + DataInputStream in = new DataInputStream( + new BufferedInputStream(new FileInputStream(logFile), 128)); try { readHeader(in); @@ -160,7 +163,8 @@ */ public void init(long previousRevision) throws IOException { if (isNew) { - DataOutputStream out = new DataOutputStream(new FileOutputStream(logFile)); + DataOutputStream out = new DataOutputStream( + new BufferedOutputStream(new FileOutputStream(logFile), 128)); try { writeHeader(out); @@ -274,12 +278,14 @@ public long append(String journalId, String producerId, InputStream in, int length) throws IOException { - DataOutputStream out = new DataOutputStream(new FileOutputStream(logFile, true)); + OutputStream out = new FileOutputStream(logFile, true); try { - out.writeUTF(journalId); - out.writeUTF(producerId); - out.writeInt(length); + DataBuffer buffer = new DataBuffer(); + buffer.writeUTF(journalId); + buffer.writeUTF(producerId); + buffer.writeInt(length); + buffer.copy(out); IOUtils.copy(in, out); out.flush(); @@ -426,4 +432,28 @@ } return utflen; } + + /** + * A simple helper class that writes to a buffer. The current buffer can + * be {@link #copy copied} to an output stream. + */ + private static final class DataBuffer extends DataOutputStream { + + public DataBuffer() { + super(new ByteArrayOutputStream()); + } + + /** + * Copies the bytes the are currently held in the buffer to the given + * output stream. + * + * @param out the output stream where the buffered data is written. + * @throws IOException if an error occurs while writing data to + * out. + */ + public void copy(OutputStream out) throws IOException { + byte[] buffer = ((ByteArrayOutputStream) super.out).toByteArray(); + out.write(buffer); + } + } }