You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2025/01/08 05:37:11 UTC
(jackrabbit-oak) branch trunk updated: OAK-11359: Remove usage of Guava Ints.checkedCast (#1957)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 651b6d7d2f OAK-11359: Remove usage of Guava Ints.checkedCast (#1957)
651b6d7d2f is described below
commit 651b6d7d2fd05366f699bb6da4188eaac69200f9
Author: Julian Reschke <re...@apache.org>
AuthorDate: Wed Jan 8 06:37:05 2025 +0100
OAK-11359: Remove usage of Guava Ints.checkedCast (#1957)
---
.../oak/plugins/index/lucene/directory/OakBufferedIndexFile.java | 3 +--
.../plugins/index/lucene/invalidData/InvalidIndexDefinitionTest.java | 4 ++--
.../apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java | 4 +---
.../apache/jackrabbit/oak/plugins/index/search/util/ConfigUtil.java | 4 +---
4 files changed, 5 insertions(+), 10 deletions(-)
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 ce0f3c6d00..db6b1d7f45 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.ArrayList;
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 @@ class OakBufferedIndexFile implements OakIndexFile {
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 dcc9c5eebe..bfac846b34 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 class InvalidIndexDefinitionTest extends AbstractQueryTest {
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 class InvalidIndexDefinitionTest extends AbstractQueryTest {
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 b1ba9e8f7a..325cd85c7d 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 @@ public class IndexDefinition implements Aggregate.AggregateMapper {
}
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 fecf6fb985..2b34a94b1a 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 class ConfigUtil {
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);
}