HADOOP-14523. OpensslAesCtrCryptoCodec.finalize() holds excessive amounts of memory. Contributed by Misha Dmitriev.

(cherry picked from commit ef8edab930)
This commit is contained in:
Xiao Chen 2017-06-15 10:40:59 -07:00
parent 0fd0612896
commit 7d81b0beab
2 changed files with 5 additions and 11 deletions

View File

@ -19,7 +19,6 @@ package org.apache.hadoop.crypto;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_SECURE_RANDOM_IMPL_KEY; import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_SECURE_RANDOM_IMPL_KEY;
import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
@ -71,16 +70,6 @@ public class OpensslAesCtrCryptoCodec extends AesCtrCryptoCodec {
} }
} }
@Override
protected void finalize() throws Throwable {
try {
Closeable r = (Closeable) this.random;
r.close();
} catch (ClassCastException e) {
}
super.finalize();
}
@Override @Override
public Configuration getConf() { public Configuration getConf() {
return conf; return conf;

View File

@ -116,4 +116,9 @@ public class OsSecureRandom extends Random implements Closeable, Configurable {
stream = null; stream = null;
} }
} }
@Override
protected void finalize() throws Throwable {
close();
}
} }