This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push:
new b1bbc2cb1 Allow test to fail with OutOfMemoryError
b1bbc2cb1 is described below
commit b1bbc2cb1bb14081d024a7da31929bfe7f98914b
Author: Alex Herbert <[email protected]>
AuthorDate: Tue Oct 20 13:39:54 2026 +0100
Allow test to fail with OutOfMemoryError
---
.../legacy/field/linalg/FP64FieldDenseMatrixTest.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git
a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/linalg/FP64FieldDenseMatrixTest.java
b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/linalg/FP64FieldDenseMatrixTest.java
index 339eb24f6..11991b83d 100644
---
a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/linalg/FP64FieldDenseMatrixTest.java
+++
b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/linalg/FP64FieldDenseMatrixTest.java
@@ -37,9 +37,18 @@ public class FP64FieldDenseMatrixTest {
@Test
public void testVeryLargeAllocation() {
- final int r = 1 << 15;
- final int c = 1 << 15;
- final FieldDenseMatrix<FP64> a =
FieldDenseMatrix.create(FP64Field.get(), r, c);
+ try {
+ final int r = 1 << 15;
+ final int c = 1 << 15;
+ final FieldDenseMatrix<FP64> a =
FieldDenseMatrix.create(FP64Field.get(), r, c);
+ } catch (OutOfMemoryError ignored) {
+ // This test may fail if run within a JVM with limited memory.
+ // Expected:
+ // - array size r*c too large for any JVM: IllegalArgumentException
+ // - array size r*c is possible: attempt to allocate array
+ // The purpose of the test is to verify an attempt will be made to
allocate
+ // the array of size 2^30. If an OOM error occurred then this is a
pass.
+ }
}
@Test