HHH-17770: Avoid casting long to int
This causes `NegativeArraySizeException: -1294967296` when Blob contents > 2Gb
This commit is contained in:
parent
df84bcd84e
commit
376f99dcc6
|
@ -201,7 +201,7 @@ public final class BlobProxy implements Blob, BlobImplementer {
|
|||
|
||||
@Override
|
||||
public long getLength() {
|
||||
return (int) length;
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue