kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b8316e0772553c1861c02aeb2e51b8f11dea4c005abb8a845890955b7d94f49e |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-02-25 15:20 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-03-31 16:37 +02:00 |
| Parents | e3b23ce2894b |
3 files changed
modified changelog/README.md +1 −0
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | - [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections. |
| 9 | 9 | - [improvement] JAVA-851: Improve UUIDs javadoc with regard to user-provided timestamps. |
| 10 | 10 | - [improvement] JAVA-979: Update javadoc for RegularStatement toString() and getQueryString() to indicate that consistency level and other parameters are not maintained in the query string. |
| 11 | +- [bug] JAVA-1068: Unwrap StatementWrappers when hashing the paging state. | |
| 11 | 12 | |
| 12 | 13 | |
| 13 | 14 | ### 3.0.0 |
modified driver-core/src/main/java/com/datastax/driver/core/PagingState.java +3 −0
| @@ -74,6 +74,9 @@ | ||
| 74 | 74 | byte[] digest; |
| 75 | 75 | ByteBuffer[] values; |
| 76 | 76 | MessageDigest md; |
| 77 | + if (statement instanceof StatementWrapper) { | |
| 78 | + statement = ((StatementWrapper) statement).getWrappedStatement(); | |
| 79 | + } | |
| 77 | 80 | assert !(statement instanceof BatchStatement); |
| 78 | 81 | try { |
| 79 | 82 | md = MessageDigest.getInstance("MD5"); |
modified driver-core/src/test/java/com/datastax/driver/core/PagingStateTest.java +26 −0
| @@ -112,6 +112,27 @@ | ||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | + /** | |
| 116 | + * Validates that {@link PagingState} can be reused with a wrapped Statement. | |
| 117 | + * | |
| 118 | + * @test_category paging | |
| 119 | + * @expected_result {@link ResultSet} from the query with the provided {@link PagingState} starts from the | |
| 120 | + * subsequent row from the first query. | |
| 121 | + */ | |
| 122 | + @Test(groups = "short") | |
| 123 | + public void should_use_state_with_wrapped_statement() { | |
| 124 | + Statement st = new TestWrapper(new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY))); | |
| 125 | + ResultSet result = session().execute(st.setFetchSize(20)); | |
| 126 | + int pageSize = result.getAvailableWithoutFetching(); | |
| 127 | + String savedPagingStateString = result.getExecutionInfo().getPagingState().toString(); | |
| 128 | + | |
| 129 | + st = new TestWrapper(new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY))); | |
| 130 | + result = session().execute(st.setFetchSize(20).setPagingState(PagingState.fromString(savedPagingStateString))); | |
| 131 | + | |
| 132 | + //We have the result starting from the next page we stopped | |
| 133 | + assertThat(result.one().getInt("v")).isEqualTo(pageSize); | |
| 134 | + } | |
| 135 | + | |
| 115 | 136 | /** |
| 116 | 137 | * Validates that {@link PagingState} can be reused with the same {@link BoundStatement}. |
| 117 | 138 | * |
| @@ -224,5 +245,10 @@ | ||
| 224 | 245 | assertThat(result.one().getInt("v")).isEqualTo(pageSize); |
| 225 | 246 | } |
| 226 | 247 | |
| 248 | + static class TestWrapper extends StatementWrapper { | |
| 249 | + TestWrapper(Statement wrapped) { | |
| 250 | + super(wrapped); | |
| 251 | + } | |
| 252 | + } | |
| 227 | 253 | } |
| 228 | 254 |