You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by co...@apache.org on 2017/01/20 11:22:19 UTC
incubator-ranger git commit: Fixing coverity issues
Repository: incubator-ranger
Updated Branches:
refs/heads/master 1f855bcf9 -> 6b03a286b
Fixing coverity issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/6b03a286
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/6b03a286
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/6b03a286
Branch: refs/heads/master
Commit: 6b03a286b188b98928251bce2637ba080f2f9f41
Parents: 1f855bc
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Fri Jan 20 11:22:07 2017 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Jan 20 11:22:07 2017 +0000
----------------------------------------------------------------------
.../authorizer/KafkaRangerAuthorizerSASLSSLTest.java | 12 ++++++++----
.../kafka/authorizer/KafkaRangerAuthorizerTest.java | 11 +++++++----
.../authorization/kafka/authorizer/KafkaTestUtils.java | 5 ++++-
3 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/6b03a286/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
----------------------------------------------------------------------
diff --git a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
index 235523b..cef9f12 100644
--- a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
+++ b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
@@ -19,6 +19,7 @@ package org.apache.ranger.authorization.kafka.authorizer;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.math.BigInteger;
import java.net.ServerSocket;
import java.security.KeyStore;
@@ -28,6 +29,7 @@ import java.util.concurrent.Future;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;
+import org.apache.commons.io.FileUtils;
import org.apache.curator.test.TestingServer;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.kafka.clients.CommonClientConfigs;
@@ -98,7 +100,9 @@ public class KafkaRangerAuthorizerSASLSSLTest {
"cspass", "myclientkey", "ckpass", keystore);
File truststoreFile = File.createTempFile("kafkatruststore", ".jks");
- keystore.store(new FileOutputStream(truststoreFile), "security".toCharArray());
+ try (OutputStream output = new FileOutputStream(truststoreFile)) {
+ keystore.store(output, "security".toCharArray());
+ }
truststorePath = truststoreFile.getPath();
zkServer = new TestingServer();
@@ -157,15 +161,15 @@ public class KafkaRangerAuthorizerSASLSSLTest {
File clientKeystoreFile = new File(clientKeystorePath);
if (clientKeystoreFile.exists()) {
- clientKeystoreFile.delete();
+ FileUtils.forceDelete(clientKeystoreFile);
}
File serviceKeystoreFile = new File(serviceKeystorePath);
if (serviceKeystoreFile.exists()) {
- serviceKeystoreFile.delete();
+ FileUtils.forceDelete(serviceKeystoreFile);
}
File truststoreFile = new File(truststorePath);
if (truststoreFile.exists()) {
- truststoreFile.delete();
+ FileUtils.forceDelete(truststoreFile);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/6b03a286/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
----------------------------------------------------------------------
diff --git a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
index 80e3144..898c785 100644
--- a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
+++ b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
@@ -19,6 +19,7 @@ package org.apache.ranger.authorization.kafka.authorizer;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.math.BigInteger;
import java.net.ServerSocket;
import java.nio.file.Files;
@@ -91,7 +92,9 @@ public class KafkaRangerAuthorizerTest {
"cspass", "myclientkey", "ckpass", keystore);
File truststoreFile = File.createTempFile("kafkatruststore", ".jks");
- keystore.store(new FileOutputStream(truststoreFile), "security".toCharArray());
+ try (OutputStream output = new FileOutputStream(truststoreFile)) {
+ keystore.store(output, "security".toCharArray());
+ }
truststorePath = truststoreFile.getPath();
zkServer = new TestingServer();
@@ -151,15 +154,15 @@ public class KafkaRangerAuthorizerTest {
File clientKeystoreFile = new File(clientKeystorePath);
if (clientKeystoreFile.exists()) {
- clientKeystoreFile.delete();
+ FileUtils.forceDelete(clientKeystoreFile);
}
File serviceKeystoreFile = new File(serviceKeystorePath);
if (serviceKeystoreFile.exists()) {
- serviceKeystoreFile.delete();
+ FileUtils.forceDelete(serviceKeystoreFile);
}
File truststoreFile = new File(truststorePath);
if (truststoreFile.exists()) {
- truststoreFile.delete();
+ FileUtils.forceDelete(truststoreFile);
}
if (tempDir != null) {
FileUtils.deleteDirectory(tempDir.toFile());
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/6b03a286/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaTestUtils.java
----------------------------------------------------------------------
diff --git a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaTestUtils.java b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaTestUtils.java
index 3186615..c71ddd3 100644
--- a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaTestUtils.java
+++ b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaTestUtils.java
@@ -19,6 +19,7 @@ package org.apache.ranger.authorization.kafka.authorizer;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -62,7 +63,9 @@ public final class KafkaTestUtils {
keystore.setKeyEntry(keystoreAlias, keyPair.getPrivate(), keyPassword.toCharArray(), new Certificate[] {certificate});
File keystoreFile = File.createTempFile("kafkakeystore", ".jks");
- keystore.store(new FileOutputStream(keystoreFile), keystorePassword.toCharArray());
+ try (OutputStream output = new FileOutputStream(keystoreFile)) {
+ keystore.store(output, keystorePassword.toCharArray());
+ }
// Now store the Certificate in the truststore
trustStore.setCertificateEntry(keystoreAlias, certificate);