Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
4.3.0
-
None
-
None
-
Linux lnxx64r6 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Description
1. PROBLEM DESCRIPTION:
-------------------------------------
get java.lang.ArrayIndexOutOfBoundsException on a particular query when invoking ResultSet.next().
The query is:
SELECT MAX( CAST( RTRIM(T1."F02CHAR_10") AS CHAR(10) ) ) FROM SDLJUNK T1
2. THE EXCEPTION CALL STACK TRACE:
---------------------------------------------------
Exception: java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method)
at org.apache.phoenix.schema.KeyValueSchema.toBytes(KeyValueSchema.java:120)
at org.apache.phoenix.schema.KeyValueSchema.toBytes(KeyValueSchema.java:91)
at org.apache.phoenix.expression.aggregator.Aggregators.toBytes(Aggregators.java:109)
at org.apache.phoenix.iterate.BaseGroupedAggregatingResultIterator.next(BaseGroupedAggregatingResultIterator.java:82)
at org.apache.phoenix.iterate.UngroupedAggregatingResultIterator.next(UngroupedAggregatingResultIterator.java:39)
at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixResultSet.java:756)
at repro1.main(repro1.java:90)
3. THIS IS THE TEST PROGRAM:
-------------------------------------------
/*
- It may be freely used, modified, and distributed with no restrictions.
*/
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSetMetaData;
import java.io.Reader;
/**
*/
public class repro1
{
/**
- Main method.
- @param args
- no arguments required
*/
public static void main(String [] args)
{
Connection con = null;
Statement stmt = null;
ResultSet rst = null;
String drptab = "DROP TABLE SDLJUNK";
String crttab = "CREATE TABLE SDLJUNK(FA01INT INTEGER PRIMARY KEY, F02CHAR_10 CHAR(10))";
String instab = "UPSERT INTO SDLJUNK VALUES (1, 'ABC' )";
String seltab = "SELECT MAX( CAST( RTRIM(T1.\"F02CHAR_10\") AS CHAR(10) ) ) FROM SDLJUNK T1";
try {
System.out.println("=================================================");
System.out.println("Problem description:");
System.out.println("Getting java.lang.ArrayIndexOutOfBoundsException");
System.out.println("when doing a specific query. ");
System.out.println("Failure happens on ResultSet.next() method call.");
System.out.println("=================================================");
System.out.println("");
// Create new instance of JDBC Driver and make connection.
System.out.println("Registering Driver.");
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
String url="jdbc:phoenix:cdh5:2181";
System.out.println("Making a connection to: "+url);
con = DriverManager.getConnection(url, null, null);
System.out.println("Connection successful.\n");
try
{ System.out.println("con.createStatement()"); stmt = con.createStatement(); System.out.println(drptab); stmt.executeUpdate(drptab); }catch (Exception ex)
{ System.out.println("Exception: " + ex); } System.out.println(crttab);
stmt.executeUpdate(crttab);
System.out.println("preparing: "+instab);
PreparedStatement pstmt = con.prepareStatement(instab);
System.out.println("executing: "+instab);
pstmt.executeUpdate();
System.out.println("committing");
con.commit();
System.out.println("preparing: "+seltab);
pstmt = con.prepareStatement(seltab);
System.out.println("executing: "+seltab);
pstmt.execute();
System.out.println("pstmt.getResultSet()");
ResultSet rs = pstmt.getResultSet();
if (rs != null)
{
System.out.println("issuing rs.next()");
if (rs.next())
else
{ System.out.println("rs.next() returned false"); } }
else
System.out.println("No records fetched");
}
catch (Exception ex)
{ System.out.println("Exception: " + ex); ex.printStackTrace(); } finally
{
if (con != null)
{
try
catch (SQLException ex)
{ System.out.println("SQLException: " + ex); } }
}
}
//-------------------------------------------------------------------
// dispResultSet
// Displays all columns and rows in the given result set
//-------------------------------------------------------------------
private static void dispResultSet (ResultSet rs)
throws SQLException
{
int i;
// Get the ResultSetMetaData. This will be used for
// the column headings
ResultSetMetaData rsmd = rs.getMetaData ();
// Get the number of columns in the result set
int numCols = rsmd.getColumnCount ();
// Display column headings
for (i=1; i<=numCols; i++)
{ if (i > 1) System.out.print(","); System.out.print(rsmd.getColumnLabel(i)); }System.out.println("");
// Display data, fetching until end of the result set
boolean more = rs.next ();
while (more) {
// Loop through each column, getting the
// column data and displaying
for (i=1; i<=numCols; i++)
{ if (i > 1) System.out.print(","); System.out.print(rs.getString(i)); }System.out.println("");
// Fetch the next result set row
more = rs.next ();
}
}
}
4. THIS IS THE ENVIRONMENT:
------------------------------------------
export JDK_HOME=/usr/java/jdk1.7.0_05
export JAVA_HOME=/usr/java/jdk1.7.0_05
export CLASSPATH=.:/qas/phoenix/phoenix-4.3.1-client.jar:/qas/phoenix/slf4j-api-1.7.5.jar
export PATH=$JDK_HOME/bin:$PATH
5. THIS IS THE TEST PROGRAM OUTPUT:
-------------------------------------------------------
Picked up _JAVA_OPTIONS: -Xms128m -Xmx256m
=================================================
Problem description:
Getting java.lang.ArrayIndexOutOfBoundsException
when doing a specific query.
Failure happens on ResultSet.next() method call.
=================================================
Registering Driver.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Making a connection to: jdbc:phoenix:cdh5:2181
log4j:WARN No appenders could be found for logger (org.apache.hadoop.conf.Configuration.deprecation).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Connection successful.
con.createStatement()
DROP TABLE SDLJUNK
CREATE TABLE SDLJUNK(FA01INT INTEGER PRIMARY KEY, F02CHAR_10 CHAR(10))
preparing: UPSERT INTO SDLJUNK VALUES (1, 'ABC' )
executing: UPSERT INTO SDLJUNK VALUES (1, 'ABC' )
committing
preparing: SELECT MAX( CAST( RTRIM(T1."F02CHAR_10") AS CHAR(10) ) ) FROM SDLJUNK T1
executing: SELECT MAX( CAST( RTRIM(T1."F02CHAR_10") AS CHAR(10) ) ) FROM SDLJUNK T1
pstmt.getResultSet()
issuing rs.next()
Exception: java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.phoenix.schema.KeyValueSchema.toBytes(KeyValueSchema.java:120)
at org.apache.phoenix.schema.KeyValueSchema.toBytes(KeyValueSchema.java:91)
at org.apache.phoenix.expression.aggregator.Aggregators.toBytes(Aggregators.java:109)
at org.apache.phoenix.iterate.BaseGroupedAggregatingResultIterator.next(BaseGroupedAggregatingResultIterator.java:82)
at org.apache.phoenix.iterate.UngroupedAggregatingResultIterator.next(UngroupedAggregatingResultIterator.java:39)
at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixResultSet.java:756)
at repro1.main(repro1.java:90)