db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r597123 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
Date Wed, 21 Nov 2007 15:52:35 GMT
Author: dag
Date: Wed Nov 21 07:52:35 2007
New Revision: 597123

URL: http://svn.apache.org/viewvc?rev=597123&view=rev
Log:
DERBY-3215 Potential NullPointerException in CachedPage class

Patch DERBY-3215b; code cleanup follow-up, no semantic change.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java?rev=597123&r1=597122&r2=597123&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java Wed
Nov 21 07:52:35 2007
@@ -23,22 +23,17 @@
 
 import org.apache.derby.iapi.reference.SQLState;
 
-import org.apache.derby.impl.store.raw.data.BasePage;
-
 import org.apache.derby.iapi.store.raw.log.LogInstant;
-import org.apache.derby.iapi.store.raw.ContainerHandle;
 import org.apache.derby.iapi.store.raw.PageKey;
 
 import org.apache.derby.iapi.services.cache.Cacheable;
 import org.apache.derby.iapi.services.cache.CacheManager;
-import org.apache.derby.iapi.services.context.ContextService;
 
 import org.apache.derby.iapi.services.monitor.Monitor;
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.services.io.FormatIdUtil;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.error.ExceptionSeverity;
@@ -768,72 +763,70 @@
 		FileContainer myContainer = 
             (FileContainer) containerCache.find(identity.getContainerId());
 
-		if (myContainer != null) 
-        {
-			try 
-            {
-				myContainer.writePage(
-                    identity.getPageNumber(), pageData, syncMe);
+		if (myContainer == null)
+		{
+			StandardException nested =
+				StandardException.newException(
+					SQLState.DATA_CONTAINER_VANISHED,
+					identity.getContainerId());
+			throw dataFactory.markCorrupt(
+				StandardException.newException(
+					SQLState.FILE_WRITE_PAGE_EXCEPTION, nested,
+					identity));
+		}
+
+		try
+		{
+			myContainer.writePage(
+				identity.getPageNumber(), pageData, syncMe);
+
+			//
+			// Do some in memory unlogged bookkeeping tasks while we have
+			// the container.
+			//
+
+			if (!isOverflowPage() && isDirty())
+			{
+
+				// let the container knows whether this page is a not
+				// filled, non-overflow page
+				myContainer.trackUnfilledPage(
+					identity.getPageNumber(), unfilled());
 
+				// if this is not an overflow page, see if the page's row
+				// count has changed since it come into the cache.
 				//
-				// Do some in memory unlogged bookkeeping tasks while we have
-				// the container. 
+				// if the page is not invalid, row count is 0.	Otherwise,
+				// count non-deleted records on page.
 				//
+				// Cannot call nonDeletedRecordCount because the page is
+				// unlatched now even though nobody is changing it
+				int currentRowCount = internalNonDeletedRecordCount();
 
-				if (!isOverflowPage() && isDirty())
+				if (currentRowCount != initialRowCount)
 				{
+					myContainer.updateEstimatedRowCount(
+						currentRowCount - initialRowCount);
 
-					// let the container knows whether this page is a not 
-                    // filled, non-overflow page
-					myContainer.trackUnfilledPage(
-                        identity.getPageNumber(), unfilled());
-
-					// if this is not an overflow page, see if the page's row
-					// count has changed since it come into the cache.
-					//
-					// if the page is not invalid, row count is 0.  Otherwise,
-					// count non-deleted records on page.
-					//
-					// Cannot call nonDeletedRecordCount because the page is
-					// unlatched now even though nobody is changing it
-					int currentRowCount = internalNonDeletedRecordCount();
-
-					if (currentRowCount != initialRowCount)
-					{
-						myContainer.updateEstimatedRowCount(
-                            currentRowCount - initialRowCount);
-
-						setContainerRowCount(
-                            myContainer.getEstimatedRowCount(0));
+					setContainerRowCount(
+						myContainer.getEstimatedRowCount(0));
 
-						initialRowCount = currentRowCount;
-					}
+					initialRowCount = currentRowCount;
 				}
-
-			} 
-            catch (IOException ioe) 
-            {
-				// page cannot be written
-				throw StandardException.newException(
-                    SQLState.FILE_WRITE_PAGE_EXCEPTION, 
-                    ioe, identity);
-			}
-			finally
-			{
-				containerCache.release(myContainer);
-				myContainer = null;
 			}
-		} 
-		else
+
+		}
+		catch (IOException ioe)
 		{
-			StandardException nested = 
-                StandardException.newException(
-                    SQLState.DATA_CONTAINER_VANISHED, 
-                    identity.getContainerId());
-			throw dataFactory.markCorrupt(
-                StandardException.newException(
-                    SQLState.FILE_WRITE_PAGE_EXCEPTION, nested, 
-                    identity));
+			// page cannot be written
+			throw StandardException.newException(
+				SQLState.FILE_WRITE_PAGE_EXCEPTION,
+				ioe, identity);
+		}
+		finally
+		{
+			containerCache.release(myContainer);
+			myContainer = null;
 		}
 
 		synchronized (this) 



Mime
View raw message