Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11359: Remove usage of Guava Ints.checkedCast #1957

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Loading