db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r535521 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/io/DebugByteTeeOutputStream.java impl/store/access/heap/Heap.java
Date Sat, 05 May 2007 13:27:07 GMT
Author: mikem
Date: Sat May  5 06:27:06 2007
New Revision: 535521

URL: http://svn.apache.org/viewvc?view=rev&rev=535521
Log:
DERBY-2598

Fixes upgrade bug in writeExternal of Heap, it was writing the wrong 
conglomerate format id in the case of a hard upgrade accessing an 
existing Heap from an old database.  It was writing out the hardcoded
new format
id when it should have been writing out the dynamic one in the class's
state.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java?view=diff&rev=535521&r1=535520&r2=535521
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java
Sat May  5 06:27:06 2007
@@ -22,6 +22,7 @@
 
 import java.io.*;
 import org.apache.derby.iapi.services.io.AccessibleByteArrayOutputStream;
+import org.apache.derby.iapi.services.sanity.SanityManager;
 
 
 class DebugByteTeeOutputStream extends FilterOutputStream {
@@ -45,7 +46,8 @@
 
 	void checkObject(Formatable f) {
 
-		ByteArrayInputStream in = new ByteArrayInputStream(tee.getInternalByteArray(), 0, tee.size());
+		ByteArrayInputStream in = 
+            new ByteArrayInputStream(tee.getInternalByteArray(), 0, tee.size());
 
 		FormatIdInputStream fin = new FormatIdInputStream(in);
 
@@ -70,22 +72,39 @@
 			if ((f1.hashCode() == System.identityHashCode(f1)) &&
 				(f.hashCode() == System.identityHashCode(f)))
 				return;
+
 		} catch (Throwable t) {
-			System.out.println("FormatableError:read error    : " + t.toString());
-			System.out.println("FormatableError:class written : " + f.getClass());
-            if( null == f1)
-                System.out.println("FormatableError:read back as null");
-            else
-                System.out.println("FormatableError:class read    : " + f1.getClass());
-			System.out.println("FormatableError:write id      : " + FormatIdUtil.formatIdToString(f.getTypeFormatId()));
-            if( null != f1)
-                System.out.println("FormatableError:read id       : " + FormatIdUtil.formatIdToString(f1.getTypeFormatId()));
+
+            // for debugging purposes print this both to derby.log and to
+            // System.out.
+            String err_msg = 
+                "FormatableError:read error    : " + t.toString() + 
+                "\nFormatableError:class written : " + f.getClass();
+
+            err_msg += (f1 == null) ? 
+                "FormatableError:read back as null" :
+                ("FormatableError:class read    : " + f1.getClass());
+
+            err_msg +=
+                "FormatableError:write id      : " + 
+                    FormatIdUtil.formatIdToString(f.getTypeFormatId());
+
+            if (f1 != null) {
+                err_msg += "FormatableError:read id       : " + 
+                    FormatIdUtil.formatIdToString(f1.getTypeFormatId());
+            }
+
+            System.out.println(err_msg);
 			t.printStackTrace(System.out);
+
+            if (SanityManager.DEBUG) {
+                SanityManager.DEBUG_PRINT("DebugByteTeeOutputStream", err_msg);
+                SanityManager.showTrace(t);
+            }
 		}
 
 		//System.out.println("FormatableError:Class written " + f.getClass() + " format id " +
f.getTypeFormatId());
 		//if (f1 != null)
 			//System.out.println("FormatableError:Class read    " + f1.getClass() + " format id "
+ f1.getTypeFormatId());
 	}
-
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java?view=diff&rev=535521&r1=535520&r2=535521
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java Sat
May  5 06:27:06 2007
@@ -1144,7 +1144,7 @@
     {
 
         // write the format id of this conglomerate
-        FormatIdUtil.writeFormatIdInteger(out, this.getTypeFormatId());
+        FormatIdUtil.writeFormatIdInteger(out, conglom_format_id);
 
 		out.writeInt((int) id.getSegmentId());
         out.writeLong(id.getContainerId());



Mime
View raw message