HHH-17770: Avoid casting long to int

This causes `NegativeArraySizeException: -1294967296` when Blob contents > 2Gb
This commit is contained in:
George Gastaldi 2024-02-22 17:57:24 -03:00 committed by Christian Beikov
parent df84bcd84e
commit 376f99dcc6
2 changed files with 21 additions and 1 deletions

View File

@ -201,7 +201,7 @@ public final class BlobProxy implements Blob, BlobImplementer {
@Override
public long getLength() {
return (int) length;
return length;
}
@Override

View File

@ -0,0 +1,20 @@
package org.hibernate.engine.jdbc;
import org.hibernate.testing.orm.junit.JiraKey;
import org.junit.jupiter.api.Test;
import java.sql.Blob;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
@JiraKey("HHH-17770")
class BlobProxyTest {
@Test
void testLengthIsNotTruncated() throws SQLException {
long THREE_GB = 3 * 1024 * 1024 * 1024L;
Blob blob = BlobProxy.generateProxy(null, THREE_GB);
assertEquals(THREE_GB, blob.length());
}
}