提交 86c6dd4e 编写于 作者: D darcy

6908541: Bad resource management in java/math/BigInteger/BigIntegerTest.java

Reviewed-by: alanb
上级 c42cb79c
...@@ -499,10 +499,6 @@ javax/management/monitor/AttributeArbitraryDataTypeTest.java generic-all ...@@ -499,10 +499,6 @@ javax/management/monitor/AttributeArbitraryDataTypeTest.java generic-all
# Problems with rounding add failures on solaris-sparcv9 and -server # Problems with rounding add failures on solaris-sparcv9 and -server
java/math/BigDecimal/AddTests.java solaris-sparcv9 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 # Should be samevm? But seems problematic with samevm on windows
java/math/BigInteger/ModPow65537.java generic-all java/math/BigInteger/ModPow65537.java generic-all
......
...@@ -642,16 +642,30 @@ public class BigIntegerTest { ...@@ -642,16 +642,30 @@ public class BigIntegerTest {
for(int i = 0; i < bitPatterns.length; i++) { for(int i = 0; i < bitPatterns.length; i++) {
BigInteger b1 = new BigInteger(bitPatterns[i], 16); BigInteger b1 = new BigInteger(bitPatterns[i], 16);
BigInteger b2 = null;
File f = new File("serialtest"); File f = new File("serialtest");
FileOutputStream fos = new FileOutputStream(f); FileOutputStream fos = new FileOutputStream(f);
try {
ObjectOutputStream oos = new ObjectOutputStream(fos); ObjectOutputStream oos = new ObjectOutputStream(fos);
try {
oos.writeObject(b1); oos.writeObject(b1);
oos.flush(); oos.flush();
} finally {
oos.close(); oos.close();
}
FileInputStream fis = new FileInputStream(f); FileInputStream fis = new FileInputStream(f);
try {
ObjectInputStream ois = new ObjectInputStream(fis); ObjectInputStream ois = new ObjectInputStream(fis);
BigInteger b2 = (BigInteger)ois.readObject(); try {
b2 = (BigInteger)ois.readObject();
} finally {
ois.close();
}
} finally {
fis.close();
}
if (!b1.equals(b2) || if (!b1.equals(b2) ||
!b1.equals(b1.or(b2))) { !b1.equals(b1.or(b2))) {
...@@ -659,20 +673,40 @@ public class BigIntegerTest { ...@@ -659,20 +673,40 @@ public class BigIntegerTest {
System.err.println("Serialized failed for hex " + System.err.println("Serialized failed for hex " +
b1.toString(16)); b1.toString(16));
} }
} finally {
fos.close();
}
f.delete(); f.delete();
} }
for(int i=0; i<10; i++) { for(int i=0; i<10; i++) {
BigInteger b1 = fetchNumber(rnd.nextInt(100)); BigInteger b1 = fetchNumber(rnd.nextInt(100));
BigInteger b2 = null;
File f = new File("serialtest"); File f = new File("serialtest");
FileOutputStream fos = new FileOutputStream(f); FileOutputStream fos = new FileOutputStream(f);
try {
ObjectOutputStream oos = new ObjectOutputStream(fos); ObjectOutputStream oos = new ObjectOutputStream(fos);
try {
oos.writeObject(b1); oos.writeObject(b1);
oos.flush(); oos.flush();
} finally {
oos.close(); oos.close();
}
FileInputStream fis = new FileInputStream(f); FileInputStream fis = new FileInputStream(f);
try {
ObjectInputStream ois = new ObjectInputStream(fis); ObjectInputStream ois = new ObjectInputStream(fis);
BigInteger b2 = (BigInteger)ois.readObject(); try {
b2 = (BigInteger)ois.readObject();
} finally {
ois.close();
}
} finally {
fis.close();
}
} finally {
fos.close();
}
if (!b1.equals(b2) || if (!b1.equals(b2) ||
!b1.equals(b1.or(b2))) !b1.equals(b1.or(b2)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册