Skip to content

Commit c1163d3

Browse files
Alexandre Dutraolim7t
authored andcommitted
JAVA-1070: The Mapper should not prepare queries synchronously.
1 parent 7149d14 commit c1163d3

4 files changed

Lines changed: 445 additions & 118 deletions

File tree

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [bug] JAVA-1089: Set LWT made from BuiltStatements to non-idempotent.
3232
- [improvement] JAVA-923: Position idempotent flag on object mapper queries.
3333
- [new feature] JAVA-1019: SchemaBuilder support for CREATE/ALTER/DROP KEYSPACE.
34+
- [bug] JAVA-1070: The Mapper should not prepare queries synchronously.
3435

3536
Merged from 2.0 branch:
3637

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.mapping;
17+
18+
import com.datastax.driver.core.exceptions.DriverException;
19+
import com.datastax.driver.core.exceptions.DriverInternalError;
20+
21+
import java.util.concurrent.ExecutionException;
22+
23+
/**
24+
* Copied here from com.datastax.driver.core.DriverThrowables
25+
* because we don't want this class to be public.
26+
*/
27+
class DriverThrowables {
28+
29+
static RuntimeException propagateCause(ExecutionException e) {
30+
Throwable cause = e.getCause();
31+
32+
if (cause instanceof Error)
33+
throw ((Error) cause);
34+
35+
// We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been
36+
// created on the I/O thread receiving the response. Which means that the stacktrace associated
37+
// with said cause will make no mention of the current thread. This is painful for say, finding
38+
// out which execute() statement actually raised the exception. So instead, we re-create the
39+
// exception.
40+
if (cause instanceof DriverException)
41+
throw ((DriverException) cause).copy();
42+
else
43+
throw new DriverInternalError("Unexpected exception thrown", cause);
44+
}
45+
}

0 commit comments

Comments
 (0)