Skip to content

Commit

Permalink
Fixed geometry block count calculation to never throw exceptions
Browse files Browse the repository at this point in the history
This is required for the page cache retry logic to work correctly.
  • Loading branch information
craigtaverner authored and MishaDemianenko committed Nov 27, 2017
1 parent f89d97b commit f4f44b8
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -46,7 +46,7 @@ public int calculateNumberOfBlocksUsedForGeometry( long firstBlock )
int dimension = getDimension( firstBlock );
if ( dimension > 3 )
{
throw new UnsupportedOperationException( "Points with more than 3 dimensions are not supported in the PropertyStore" );
return PropertyType.BLOCKS_USED_FOR_BAD_TYPE_OR_ENCODING;
}
return 1 + dimension;
}
Expand Down Expand Up @@ -93,8 +93,15 @@ private static boolean isFloatPrecision( long firstBlock )

public static int calculateNumberOfBlocksUsed( long firstBlock )
{
int gtype = getGeometryType( firstBlock );
return find( gtype ).calculateNumberOfBlocksUsedForGeometry( firstBlock );
GeometryType geometryType = find( getGeometryType( firstBlock ) );
if ( geometryType == null )
{
return PropertyType.BLOCKS_USED_FOR_BAD_TYPE_OR_ENCODING;
}
else
{
return geometryType.calculateNumberOfBlocksUsedForGeometry( firstBlock );
}
}

private static GeometryType find( int gtype )
Expand All @@ -106,7 +113,7 @@ private static GeometryType find( int gtype )
return type;
}
}
throw new IllegalArgumentException( "No such GeometryType: " + gtype );
return null;
}

public static Value decode( PropertyBlock block )
Expand Down

0 comments on commit f4f44b8

Please sign in to comment.