Skip to content

Commit

Permalink
Don't use constant return value in GenericKeyState#setCursorException
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Aug 22, 2018
1 parent daa1e61 commit e12f892
Showing 1 changed file with 15 additions and 9 deletions.
Expand Up @@ -1012,13 +1012,15 @@ boolean read( PageCursor cursor, int size )
{ {
if ( size <= TYPE_ID_SIZE ) if ( size <= TYPE_ID_SIZE )
{ {
return setCursorException( cursor, "slot size less than TYPE_ID_SIZE, " + size ); setCursorException( cursor, "slot size less than TYPE_ID_SIZE, " + size );
return false;
} }


byte typeId = cursor.getByte(); byte typeId = cursor.getByte();
if ( typeId < 0 || typeId >= GenericLayout.TYPES.length ) if ( typeId < 0 || typeId >= GenericLayout.TYPES.length )
{ {
return setCursorException( cursor, "non-valid typeId, " + typeId ); setCursorException( cursor, "non-valid typeId, " + typeId );
return false;
} }


size -= TYPE_ID_SIZE; size -= TYPE_ID_SIZE;
Expand Down Expand Up @@ -1063,7 +1065,8 @@ boolean read( PageCursor cursor, int size )
case NUMBER_ARRAY: case NUMBER_ARRAY:
return readNumberArray( cursor ); return readNumberArray( cursor );
default: default:
return setCursorException( cursor, "non-valid type, " + type ); setCursorException( cursor, "non-valid type, " + type );
return false;
} }
} }


Expand Down Expand Up @@ -1091,7 +1094,8 @@ private boolean readNumberArray( PageCursor cursor )
ArrayType numberType = numberArrayTypeOf( (byte) long1 ); ArrayType numberType = numberArrayTypeOf( (byte) long1 );
if ( numberType == null ) if ( numberType == null )
{ {
return setCursorException( cursor, "non-valid number type for array, " + long1 ); setCursorException( cursor, "non-valid number type for array, " + long1 );
return false;
} }
return readArray( cursor, numberType, numberArrayElementReader( long1 ) ); return readArray( cursor, numberType, numberArrayElementReader( long1 ) );
} }
Expand Down Expand Up @@ -1175,7 +1179,8 @@ private boolean readTextArray( PageCursor cursor, int maxSize )
short bytesLength = cursor.getShort(); short bytesLength = cursor.getShort();
if ( bytesLength <= 0 || bytesLength > maxSize ) if ( bytesLength <= 0 || bytesLength > maxSize )
{ {
return setCursorException( cursor, "non-valid bytes length, " + bytesLength ); setCursorException( cursor, "non-valid bytes length, " + bytesLength );
return false;
} }


byteArrayArray[i] = ensureBigEnough( byteArrayArray[i], bytesLength ); byteArrayArray[i] = ensureBigEnough( byteArrayArray[i], bytesLength );
Expand All @@ -1191,7 +1196,8 @@ private boolean setArrayLengthWhenReading( PageCursor cursor )
arrayLength = cursor.getInt(); arrayLength = cursor.getInt();
if ( arrayLength < 0 || arrayLength > BIGGEST_REASONABLE_ARRAY_LENGTH ) if ( arrayLength < 0 || arrayLength > BIGGEST_REASONABLE_ARRAY_LENGTH )
{ {
return setCursorException( cursor, "non-valid array length, " + arrayLength ); setCursorException( cursor, "non-valid array length, " + arrayLength );
return false;
} }
return true; return true;
} }
Expand Down Expand Up @@ -1232,7 +1238,8 @@ private boolean readText( PageCursor cursor, int maxSize )
short bytesLength = cursor.getShort(); short bytesLength = cursor.getShort();
if ( bytesLength < 0 || bytesLength > maxSize ) if ( bytesLength < 0 || bytesLength > maxSize )
{ {
return setCursorException( cursor, "non-valid bytes length for text, " + bytesLength ); setCursorException( cursor, "non-valid bytes length for text, " + bytesLength );
return false;
} }
setBytesLength( bytesLength ); setBytesLength( bytesLength );
cursor.getBytes( byteArray, 0, bytesLength ); cursor.getBytes( byteArray, 0, bytesLength );
Expand Down Expand Up @@ -1837,10 +1844,9 @@ private void copyZonedDateTimeArrayFrom( GenericKeyState key, int length )
/* </copyFrom.helpers> */ /* </copyFrom.helpers> */


/* <helpers> */ /* <helpers> */
private boolean setCursorException( PageCursor cursor, String reason ) private void setCursorException( PageCursor cursor, String reason )
{ {
cursor.setCursorException( format( "Unable to read generic key slot due to %s", reason ) ); cursor.setCursorException( format( "Unable to read generic key slot due to %s", reason ) );
return false;
} }


private void setBytesLength( int length ) private void setBytesLength( int length )
Expand Down

0 comments on commit e12f892

Please sign in to comment.