phoenix git commit: PHOENIX-2368 Call Driver.accept() in Driver.getConnection and return null if false (Ram)

2016-01-11 Thread ramkrishna
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 073ed20c1 -> cc134fe15


PHOENIX-2368 Call Driver.accept() in Driver.getConnection and return null
if false (Ram)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/cc134fe1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/cc134fe1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/cc134fe1

Branch: refs/heads/4.x-HBase-0.98
Commit: cc134fe151891e88338590baa98030ff5e44bfac
Parents: 073ed20
Author: ramkrishna 
Authored: Tue Jan 12 08:16:32 2016 +0530
Committer: ramkrishna 
Committed: Tue Jan 12 08:18:47 2016 +0530

--
 .../java/org/apache/phoenix/jdbc/PhoenixDriver.java   |  5 -
 .../apache/phoenix/jdbc/PhoenixEmbeddedDriver.java| 14 +-
 .../org/apache/phoenix/jdbc/PhoenixDriverTest.java| 12 
 3 files changed, 25 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cc134fe1/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
index 0f5d4aa..9dafbbf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
@@ -183,10 +183,13 @@ public final class PhoenixDriver extends 
PhoenixEmbeddedDriver {
 
 @Override
 public Connection connect(String url, Properties info) throws SQLException 
{
+if (!acceptsURL(url)) {
+  return null;
+}
 try {
 closeLock.readLock().lock();
 checkClosed();
-return super.connect(url, info);
+return createConnection(url, info);
 } finally {
 closeLock.readLock().unlock();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cc134fe1/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
index c49bf37..486a6d7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
@@ -126,11 +126,15 @@ public abstract class PhoenixEmbeddedDriver implements 
Driver, SQLCloseable {
 return null;
 }
 
-Properties augmentedInfo = PropertiesUtil.deepCopy(info);
-augmentedInfo.putAll(getDefaultProps().asMap());
-ConnectionQueryServices connectionServices = 
getConnectionQueryServices(url, augmentedInfo);
-PhoenixConnection connection = connectionServices.connect(url, 
augmentedInfo);
-return connection;
+return createConnection(url, info);
+}
+
+protected final Connection createConnection(String url, Properties info) 
throws SQLException {
+  Properties augmentedInfo = PropertiesUtil.deepCopy(info);
+  augmentedInfo.putAll(getDefaultProps().asMap());
+  ConnectionQueryServices connectionServices = 
getConnectionQueryServices(url, augmentedInfo);
+  PhoenixConnection connection = connectionServices.connect(url, 
augmentedInfo);
+  return connection;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cc134fe1/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
index b70ea71..02af191 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
@@ -114,4 +114,16 @@ public class PhoenixDriverTest extends 
BaseConnectionlessQueryTest {
 conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
 conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
 }
+
+@Test
+public void testInvalidURL() throws Exception {
+  Class.forName(PhoenixDriver.class.getName());
+  PhoenixDriver d = (PhoenixDriver) 
DriverManager.getDriver("jdbc:phoenix");
+  d.close();
+  try {
+  DriverManager.getConnection("any text whatever you want to put here");
+  fail("Should have failed due to invalid driver");
+  } catch(Exception e) 

phoenix git commit: PHOENIX-2368 Call Driver.accept() in Driver.getConnection and return null if false (Ram)

2016-01-11 Thread ramkrishna
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 af23e6711 -> 7fc2b2f33


PHOENIX-2368 Call Driver.accept() in Driver.getConnection and return null
if false (Ram)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7fc2b2f3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7fc2b2f3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7fc2b2f3

Branch: refs/heads/4.x-HBase-1.0
Commit: 7fc2b2f33ed11666341937043b5011b8bce514fc
Parents: af23e67
Author: ramkrishna 
Authored: Tue Jan 12 08:16:32 2016 +0530
Committer: ramkrishna 
Committed: Tue Jan 12 08:18:03 2016 +0530

--
 .../java/org/apache/phoenix/jdbc/PhoenixDriver.java   |  5 -
 .../apache/phoenix/jdbc/PhoenixEmbeddedDriver.java| 14 +-
 .../org/apache/phoenix/jdbc/PhoenixDriverTest.java| 12 
 3 files changed, 25 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7fc2b2f3/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
index 0f5d4aa..9dafbbf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java
@@ -183,10 +183,13 @@ public final class PhoenixDriver extends 
PhoenixEmbeddedDriver {
 
 @Override
 public Connection connect(String url, Properties info) throws SQLException 
{
+if (!acceptsURL(url)) {
+  return null;
+}
 try {
 closeLock.readLock().lock();
 checkClosed();
-return super.connect(url, info);
+return createConnection(url, info);
 } finally {
 closeLock.readLock().unlock();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7fc2b2f3/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
index c49bf37..486a6d7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
@@ -126,11 +126,15 @@ public abstract class PhoenixEmbeddedDriver implements 
Driver, SQLCloseable {
 return null;
 }
 
-Properties augmentedInfo = PropertiesUtil.deepCopy(info);
-augmentedInfo.putAll(getDefaultProps().asMap());
-ConnectionQueryServices connectionServices = 
getConnectionQueryServices(url, augmentedInfo);
-PhoenixConnection connection = connectionServices.connect(url, 
augmentedInfo);
-return connection;
+return createConnection(url, info);
+}
+
+protected final Connection createConnection(String url, Properties info) 
throws SQLException {
+  Properties augmentedInfo = PropertiesUtil.deepCopy(info);
+  augmentedInfo.putAll(getDefaultProps().asMap());
+  ConnectionQueryServices connectionServices = 
getConnectionQueryServices(url, augmentedInfo);
+  PhoenixConnection connection = connectionServices.connect(url, 
augmentedInfo);
+  return connection;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7fc2b2f3/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
index b70ea71..02af191 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
@@ -114,4 +114,16 @@ public class PhoenixDriverTest extends 
BaseConnectionlessQueryTest {
 conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
 conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
 }
+
+@Test
+public void testInvalidURL() throws Exception {
+  Class.forName(PhoenixDriver.class.getName());
+  PhoenixDriver d = (PhoenixDriver) 
DriverManager.getDriver("jdbc:phoenix");
+  d.close();
+  try {
+  DriverManager.getConnection("any text whatever you want to put here");
+  fail("Should have failed due to invalid driver");
+  } catch(Exception e) {