From 665653b09edd80672e03a2d37e9338b915296a65 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Wed, 20 Dec 2006 20:02:49 +0000 Subject: [PATCH] RESOLVED - bug 168420: PDOM truncation fails with IBM 1.5.0 JRE https://bugs.eclipse.org/bugs/show_bug.cgi?id=168420 Fix courtesy of Jason Montojo --- .../cdt/internal/core/pdom/db/Database.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java index 7626db02d0b..52fc230bd6b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java @@ -143,6 +143,7 @@ public class Database { // Queue all the chunks to be reclaimed. ReferenceQueue queue = new ReferenceQueue(); Set references = new HashSet(); + int totalChunks = toc.length; for (int i = 0; i < toc.length; i++) { if (toc[i] != null) { toc[i].reclaim(queue, references); @@ -162,12 +163,17 @@ public class Database { // Truncate everything but the header chunk. try { file.getChannel().truncate(CHUNK_SIZE); + // Reinitialize header chunk. + toc = new Chunk[] { new Chunk(file, 0) }; + return true; } catch (IOException e) { - throw new CoreException(new DBStatus(e)); + // Bug 168420: + // Truncation failed so we'll reuse the existing + // file. + toc = new Chunk[totalChunks]; + toc[0] = new Chunk(file, 0); + return false; } - // Reinitialize header chunk. - toc = new Chunk[] { new Chunk(file, 0) }; - return true; } catch (InterruptedException e) { // Truncation took longer than we wanted, so we'll