kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 556927b79dfa04e2d6b1ba6cfd406ea4d678c33c57bbf12001c782dd7e9094b6 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2016-06-17 10:51 -07:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-06-17 10:51 -07:00 |
| Parents | 78f4644f101f, 7beeb2fc4b47 |
3 files changed
modified changelog/README.md +2 −0
| @@ -4,6 +4,8 @@ | ||
| 4 | 4 | |
| 5 | 5 | - [improvement] JAVA-1147: Upgrade Netty to 4.0.37. |
| 6 | 6 | - [bug] JAVA-1213: Allow updates and inserts to BLOB column using read-only ByteBuffer. |
| 7 | +- [bug] JAVA-1209: ProtocolOptions.getProtocolVersion() should return null instead of throwing NPE if Cluster has not | |
| 8 | + been init'd. | |
| 7 | 9 | |
| 8 | 10 | |
| 9 | 11 | ### 3.0.2 |
modified driver-core/src/main/java/com/datastax/driver/core/ProtocolOptions.java +1 −1
| @@ -165,7 +165,7 @@ | ||
| 165 | 165 | * nodes that do not support this protocol version will be ignored. |
| 166 | 166 | */ |
| 167 | 167 | public ProtocolVersion getProtocolVersion() { |
| 168 | - return manager.connectionFactory.protocolVersion; | |
| 168 | + return manager == null || manager.connectionFactory == null ? null : manager.connectionFactory.protocolVersion; | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
added driver-core/src/test/java/com/datastax/driver/core/ProtocolOptionsTest.java +41 −0
| @@ -0,0 +1,41 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core; | |
| 17 | + | |
| 18 | +import org.testng.annotations.Test; | |
| 19 | + | |
| 20 | +import static com.datastax.driver.core.Assertions.assertThat; | |
| 21 | + | |
| 22 | +public class ProtocolOptionsTest extends CCMTestsSupport { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * @jira_ticket JAVA-1209 | |
| 26 | + */ | |
| 27 | + @Test(groups = "unit") | |
| 28 | + public void getProtocolVersion_should_return_null_if_not_connected() { | |
| 29 | + Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build(); | |
| 30 | + assertThat(cluster.getConfiguration().getProtocolOptions().getProtocolVersion()).isNull(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @jira_ticket JAVA-1209 | |
| 35 | + */ | |
| 36 | + @Test(groups = "short") | |
| 37 | + public void getProtocolVersion_should_return_version() throws InterruptedException { | |
| 38 | + ProtocolVersion version = cluster().getConfiguration().getProtocolOptions().getProtocolVersion(); | |
| 39 | + assertThat(version).isNotNull(); | |
| 40 | + } | |
| 41 | +} |