/*******************************************************************************
 * Copyright (c) 2008 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.core.btree;

import java.io.Serializable;
import java.util.Comparator;

public class JavaComparator<K> implements Comparator<K>, Serializable
{
	private static final long serialVersionUID = -2374485501916583296L;

	public int compare( K o1, K o2 )
	{
		if ( o1 instanceof Comparable )
		{
			return ( (Comparable) o1 ).compareTo( o2 );
		}
		if ( o2 instanceof Comparable )
		{
			return -( (Comparable) o2 ).compareTo( o1 );
		}
		return 0;
	}
}

@@ -800,16 +800,144 @@
 o2 )%0A%09%7B%0A
+%09%09if ( o1 == null )%0A%09%09%7B%0A%09%09%09if ( o2 == null )%0A%09%09%09%7B%0A%09%09%09%09return 0;%0A%09%09%09%7D%0A%09%09%09return -1;%0A%09%09%7D%0A%09%09if ( o2 == null )%0A%09%09%7B%0A%09%09%09return 1;%0A%09%09%7D%0A
 %09%09if ( o

Fix a potential NPE in comparator[T38116]