Skip to content

Commit f6d1376

Browse files
committed
Update to executeBlocking API change
1 parent 76c8336 commit f6d1376

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/Helper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,32 +296,32 @@ interface JdbcRow {
296296
}
297297

298298
@FunctionalInterface
299-
public interface SQLBlockingCodeHandler<T> extends Handler<Promise<T>> {
299+
public interface SQLBlockingCodeHandler<T> extends java.util.concurrent.Callable<T> {
300300

301301
T doHandle() throws SQLException;
302302

303303
@Override
304-
default void handle(Promise<T> promise) {
304+
default T call() {
305305
try {
306-
promise.complete(doHandle());
306+
return doHandle();
307307
} catch (SQLException e) {
308-
promise.fail(new OracleException(e));
308+
throw new OracleException(e);
309309
}
310310
}
311311
}
312312

313313
@FunctionalInterface
314-
public interface SQLBlockingTaskHandler extends Handler<Promise<Void>> {
314+
public interface SQLBlockingTaskHandler extends java.util.concurrent.Callable<Void> {
315315

316316
void doHandle() throws SQLException;
317317

318318
@Override
319-
default void handle(Promise<Void> promise) {
319+
default Void call() throws Exception {
320320
try {
321321
doHandle();
322-
promise.complete(null);
322+
return null;
323323
} catch (SQLException e) {
324-
promise.fail(new OracleException(e));
324+
throw new OracleException(e);
325325
}
326326
}
327327
}

vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/OracleJdbcConnection.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,18 @@ public int getSecretKey() {
137137

138138
public Future<Void> afterAcquire() {
139139
PromiseInternal<Void> promise = context.owner().promise();
140-
context.<Void>executeBlocking(prom -> {
141-
try {
142-
connection.beginRequest();
143-
prom.complete();
144-
} catch (SQLException e) {
145-
prom.fail(e);
146-
}
140+
context.<Void>executeBlocking(() -> {
141+
connection.beginRequest();
142+
return null;
147143
}, false).onComplete(promise);
148144
return promise.future();
149145
}
150146

151147
public Future<Void> beforeRecycle() {
152148
PromiseInternal<Void> promise = context.owner().promise();
153-
context.<Void>executeBlocking(prom -> {
154-
try {
155-
connection.endRequest();
156-
prom.complete();
157-
} catch (SQLException e) {
158-
prom.fail(e);
159-
}
149+
context.<Void>executeBlocking(() -> {
150+
connection.endRequest();
151+
return null;
160152
}, false).onComplete(promise);
161153
return promise.future();
162154
}

vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/commands/OracleQueryCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import io.vertx.core.Context;
1414
import io.vertx.core.Future;
15+
import io.vertx.core.VertxException;
1516
import io.vertx.core.buffer.Buffer;
1617
import io.vertx.core.impl.ContextInternal;
1718
import io.vertx.core.json.JsonArray;
@@ -96,7 +97,7 @@ protected boolean returnAutoGeneratedKeys(Connection conn, OraclePrepareOptions
9697
protected abstract String query();
9798

9899
private Future<OraclePreparedStatement> prepare(Connection conn, OraclePrepareOptions options, boolean returnAutoGeneratedKeys, Context context) {
99-
return context.executeBlocking(prom -> {
100+
return context.executeBlocking(() -> {
100101
String query = query();
101102
PreparedStatement ps = null;
102103
try {
@@ -119,20 +120,19 @@ private Future<OraclePreparedStatement> prepare(Connection conn, OraclePrepareOp
119120
}
120121
ps = conn.prepareStatement(query, keys);
121122
} else {
122-
prom.fail("Invalid type of index, only [int, String] allowed");
123-
return;
123+
throw new VertxException("Invalid type of index, only [int, String] allowed", true);
124124
}
125125
} else {
126126
ps = conn.prepareStatement(query());
127127
}
128128

129129
fillStatement(ps, conn);
130130

131-
prom.complete(ps.unwrap(OraclePreparedStatement.class));
131+
return ps.unwrap(OraclePreparedStatement.class);
132132

133133
} catch (SQLException e) {
134134
closeQuietly(ps);
135-
prom.fail(e);
135+
throw e;
136136
}
137137
}, false);
138138
}

0 commit comments

Comments
 (0)