HADOOP-17255. JavaKeyStoreProvider fails to create a new key if the keystore is HDFS. (#2291)
Reviewed-by: Steve Loughran <stevel@cloudera.com> Reviewed-by: Wei-Chiu Chuang <weichiu@apache.org> (cherry picked from commit7f5caca04c
) (cherry picked from commitdd1634ec3b
)
This commit is contained in:
parent
31154fdde5
commit
1c7043b1ff
|
@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataInputStream;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileContext;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
@ -103,6 +104,7 @@ public class JavaKeyStoreProvider extends KeyProvider {
|
|||
private final Path path;
|
||||
private final FileSystem fs;
|
||||
private FsPermission permissions;
|
||||
private FileContext context;
|
||||
private KeyStore keyStore;
|
||||
private char[] password;
|
||||
private boolean changed = false;
|
||||
|
@ -130,6 +132,7 @@ public class JavaKeyStoreProvider extends KeyProvider {
|
|||
this.uri = uri;
|
||||
path = ProviderUtils.unnestUri(uri);
|
||||
fs = path.getFileSystem(conf);
|
||||
context = FileContext.getFileContext(conf);
|
||||
locateKeystore();
|
||||
ReadWriteLock lock = new ReentrantReadWriteLock(true);
|
||||
readLock = lock.readLock();
|
||||
|
@ -638,10 +641,7 @@ public class JavaKeyStoreProvider extends KeyProvider {
|
|||
|
||||
private void renameOrFail(Path src, Path dest)
|
||||
throws IOException {
|
||||
if (!fs.rename(src, dest)) {
|
||||
throw new IOException("Rename unsuccessful : "
|
||||
+ String.format("'%s' to '%s'", src, dest));
|
||||
}
|
||||
context.rename(src, dest, org.apache.hadoop.fs.Options.Rename.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue