diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 9cf24b2a5e143d8b04e4879fcd430f19a83d025e..b265054a11e8220065af3d49fc4bcc881378ba35 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -499,10 +499,6 @@ javax/management/monitor/AttributeArbitraryDataTypeTest.java generic-all # Problems with rounding add failures on solaris-sparcv9 and -server java/math/BigDecimal/AddTests.java solaris-sparcv9 -# Problems on windows with samevm, missing inputstream close()? -# Also times out on solaris-sparcv9 -server -java/math/BigInteger/BigIntegerTest.java generic-all - # Should be samevm? But seems problematic with samevm on windows java/math/BigInteger/ModPow65537.java generic-all diff --git a/test/java/math/BigInteger/BigIntegerTest.java b/test/java/math/BigInteger/BigIntegerTest.java index 75ce0033779ca60178c4e8172fdffac368d8c62f..c5196eb7252262dfb487ce14d1e83cdf784c9987 100644 --- a/test/java/math/BigInteger/BigIntegerTest.java +++ b/test/java/math/BigInteger/BigIntegerTest.java @@ -642,37 +642,71 @@ public class BigIntegerTest { for(int i = 0; i < bitPatterns.length; i++) { BigInteger b1 = new BigInteger(bitPatterns[i], 16); + BigInteger b2 = null; File f = new File("serialtest"); FileOutputStream fos = new FileOutputStream(f); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(b1); - oos.flush(); - oos.close(); - FileInputStream fis = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fis); - BigInteger b2 = (BigInteger)ois.readObject(); + try { + ObjectOutputStream oos = new ObjectOutputStream(fos); + try { + oos.writeObject(b1); + oos.flush(); + } finally { + oos.close(); + } - if (!b1.equals(b2) || - !b1.equals(b1.or(b2))) { - failCount++; - System.err.println("Serialized failed for hex " + - b1.toString(16)); + FileInputStream fis = new FileInputStream(f); + try { + ObjectInputStream ois = new ObjectInputStream(fis); + try { + b2 = (BigInteger)ois.readObject(); + } finally { + ois.close(); + } + } finally { + fis.close(); + } + + if (!b1.equals(b2) || + !b1.equals(b1.or(b2))) { + failCount++; + System.err.println("Serialized failed for hex " + + b1.toString(16)); + } + } finally { + fos.close(); } f.delete(); } for(int i=0; i<10; i++) { BigInteger b1 = fetchNumber(rnd.nextInt(100)); + BigInteger b2 = null; File f = new File("serialtest"); FileOutputStream fos = new FileOutputStream(f); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(b1); - oos.flush(); - oos.close(); - FileInputStream fis = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fis); - BigInteger b2 = (BigInteger)ois.readObject(); + try { + ObjectOutputStream oos = new ObjectOutputStream(fos); + try { + oos.writeObject(b1); + oos.flush(); + } finally { + oos.close(); + } + + FileInputStream fis = new FileInputStream(f); + try { + ObjectInputStream ois = new ObjectInputStream(fis); + try { + b2 = (BigInteger)ois.readObject(); + } finally { + ois.close(); + } + } finally { + fis.close(); + } + } finally { + fos.close(); + } if (!b1.equals(b2) || !b1.equals(b1.or(b2)))