You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2008/01/10 18:23:21 UTC

svn commit: r610846 - in /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types: CollatorSQLChar.java CollatorSQLClob.java CollatorSQLLongvarchar.java CollatorSQLVarchar.java SQLChar.java

Author: mamta
Date: Thu Jan 10 09:22:57 2008
New Revision: 610846

URL: http://svn.apache.org/viewvc?rev=610846&view=rev
Log:
DERBY-3302 The user was running into null pointer exception at the time of database recovery
because Derby was trying to get the Collator object through database context. But the 
Collator object is already available in the territory sensitive character classes and we
do not have to go to database context to get it. I changed the code to use that collator 
object rather than look into database context. The reason for null pointer exception was 
that database context was not loaded yet during database recovery.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLLongvarchar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLChar.java?rev=610846&r1=610845&r2=610846&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLChar.java Thu Jan 10 09:22:57 2008
@@ -74,6 +74,18 @@
 		holderForCollationSensitiveInfo = 
 			new WorkHorseForCollatorDatatypes(collatorForCharacterDatatypes, this);
 	}
+
+	/**
+	 * Get the RuleBasedCollator for this instance of CollatorSQLChar. It 
+	 * will be used to do the collation.
+	 * 
+	 * @return	The Collator object which should be used for collation 
+	 * operation on this object
+	 */
+	protected RuleBasedCollator getCollatorForCollation() throws StandardException
+	{
+		return holderForCollationSensitiveInfo.getCollatorForCollation();
+	}
 	
 	/** @see CollationElementsInterface#getCollationElementsForString */
 	public int[] getCollationElementsForString() throws StandardException 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java?rev=610846&r1=610845&r2=610846&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java Thu Jan 10 09:22:57 2008
@@ -75,6 +75,18 @@
 		holderForCollationSensitiveInfo = 
 			new WorkHorseForCollatorDatatypes(collatorForCharacterDatatypes, this);
 	}
+
+	/**
+	 * Get the RuleBasedCollator for this instance of CollatorSQLClob. It 
+	 * will be used to do the collation.
+	 * 
+	 * @return	The Collator object which should be used for collation 
+	 * operation on this object
+	 */
+	protected RuleBasedCollator getCollatorForCollation() throws StandardException
+	{
+		return holderForCollationSensitiveInfo.getCollatorForCollation();
+	}
 	
 	/** @see CollationElementsInterface#getCollationElementsForString */
 	public int[] getCollationElementsForString() throws StandardException 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLLongvarchar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLLongvarchar.java?rev=610846&r1=610845&r2=610846&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLLongvarchar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLLongvarchar.java Thu Jan 10 09:22:57 2008
@@ -76,6 +76,18 @@
 		holderForCollationSensitiveInfo = 
 			new WorkHorseForCollatorDatatypes(collatorForCharacterDatatypes, this);
 	}
+
+	/**
+	 * Get the RuleBasedCollator for this instance of CollatorSQLLongvarchar. 
+	 * It will be used to do the collation.
+	 * 
+	 * @return	The Collator object which should be used for collation 
+	 * operation on this object
+	 */
+	protected RuleBasedCollator getCollatorForCollation() throws StandardException
+	{
+		return holderForCollationSensitiveInfo.getCollatorForCollation();
+	}
 	
 	/** @see CollationElementsInterface#getCollationElementsForString */
 	public int[] getCollationElementsForString() throws StandardException 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java?rev=610846&r1=610845&r2=610846&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java Thu Jan 10 09:22:57 2008
@@ -75,6 +75,18 @@
 		holderForCollationSensitiveInfo = 
 			new WorkHorseForCollatorDatatypes(collatorForCharacterDatatypes, this);
 	}
+
+	/**
+	 * Get the RuleBasedCollator for this instance of CollatorSQLVarchar. It 
+	 * will be used to do the collation.
+	 * 
+	 * @return	The Collator object which should be used for collation 
+	 * operation on this object
+	 */
+	protected RuleBasedCollator getCollatorForCollation() throws StandardException
+	{
+		return holderForCollationSensitiveInfo.getCollatorForCollation();
+	}
 	
 	/** @see CollationElementsInterface#getCollationElementsForString */
 	public int[] getCollationElementsForString() throws StandardException 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=610846&r1=610845&r2=610846&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Thu Jan 10 09:22:57 2008
@@ -2492,6 +2492,16 @@
 		return ckey1.compareTo(ckey2);
 	}
 		
+	/**
+	 * This method gets called for the collation sensitive char classes ie
+	 * CollatorSQLChar, CollatorSQLVarchar, CollatorSQLLongvarchar,
+	 * CollatorSQLClob. These collation sensitive chars need to have the 
+	 * collation key in order to do string comparison. And the collation key
+	 * is obtained using the Collator object that these classes already have.
+	 * 
+	 * @return CollationKey obtained using Collator on the string
+	 * @throws StandardException
+	 */
 	protected CollationKey getCollationKey() throws StandardException
 	{
 		char tmpCharArray[];
@@ -2513,7 +2523,7 @@
 			   rawData[lastNonspaceChar - 1] == '\u0020')
 			lastNonspaceChar--;			// count off the trailing spaces.
 
-		RuleBasedCollator rbc = getLocaleFinder().getCollator();		
+		RuleBasedCollator rbc = getCollatorForCollation();		
 		cKey = rbc.getCollationKey(new String(rawData, 0, lastNonspaceChar));
 
 		return cKey;
@@ -2746,6 +2756,11 @@
 	private Locale getLocale() throws StandardException
 	{
 		return getLocaleFinder().getCurrentLocale();
+	}
+
+	protected RuleBasedCollator getCollatorForCollation() throws StandardException
+	{
+		return getLocaleFinder().getCollator();
 	}
 
 	protected LocaleFinder getLocaleFinder()