diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java index ce0f3c6d006..db6b1d7f45d 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java @@ -24,7 +24,6 @@ import java.util.List; import org.apache.jackrabbit.guava.common.io.ByteStreams; -import org.apache.jackrabbit.guava.common.primitives.Ints; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; @@ -312,7 +311,7 @@ public void copyBytes(DataInput input, long numBytes) throws IOException { private static int determineBlobSize(NodeBuilder file){ if (file.hasProperty(OakDirectory.PROP_BLOB_SIZE)){ - return Ints.checkedCast(file.getProperty(OakDirectory.PROP_BLOB_SIZE).getValue(Type.LONG)); + return Math.toIntExact(file.getProperty(OakDirectory.PROP_BLOB_SIZE).getValue(Type.LONG)); } return DEFAULT_BLOB_SIZE; } diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/invalidData/InvalidIndexDefinitionTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/invalidData/InvalidIndexDefinitionTest.java index dcc9c5eebeb..bfac846b348 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/invalidData/InvalidIndexDefinitionTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/invalidData/InvalidIndexDefinitionTest.java @@ -121,7 +121,7 @@ public void invalidQueryFilterRegex() throws CommitFailedException { root.commit(); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = RuntimeException.class) public void invalidBlobSize() throws CommitFailedException { Tree def = createIndexNodeAndData(); // 1L + Integer.MAX_VALUE results in IllegalArgumentException: Out of range: 2147483648 @@ -140,7 +140,7 @@ public void negativeBlobSize() throws CommitFailedException { assertQuery(query, List.of("/tmp/testNode")); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = RuntimeException.class) public void invalidMaxFieldLength() throws CommitFailedException { Tree def = createIndexNodeAndData(); // 1L + Integer.MAX_VALUE results in IllegalArgumentException: Out of range: 2147483648 diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java index b1ba9e8f7ae..325cd85c7dd 100644 --- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java +++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java @@ -16,12 +16,10 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.search; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.primitives.Ints; import org.apache.jackrabbit.oak.api.IllegalRepositoryStateException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -1892,7 +1890,7 @@ private static IndexFormatVersion determineVersionForFreshIndex(PropertyState fu } private static IndexFormatVersion versionFrom(PropertyState ps) { - return IndexFormatVersion.getVersion(Ints.checkedCast(ps.getValue(Type.LONG))); + return IndexFormatVersion.getVersion(Math.toIntExact(ps.getValue(Type.LONG))); } private static boolean hasIndexingRules(NodeState defn) { diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/ConfigUtil.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/ConfigUtil.java index fecf6fb985d..2b34a94b1aa 100644 --- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/ConfigUtil.java +++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/ConfigUtil.java @@ -16,13 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.search.util; import java.util.Collections; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.primitives.Ints; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; @@ -51,7 +49,7 @@ public static boolean getOptionalValue(NodeState definition, String propName, bo public static int getOptionalValue(NodeState definition, String propName, int defaultVal) { try { PropertyState ps = definition.getProperty(propName); - return ps == null ? defaultVal : Ints.checkedCast(ps.getValue(Type.LONG)); + return ps == null ? defaultVal : Math.toIntExact(ps.getValue(Type.LONG)); } catch (IllegalStateException e) { throw new IllegalStateException(String.format(ILLEGAL_STATE_EXCEPTION_ERROR_MESSAGE, propName), e); }