|
1 | 1 | /* |
2 | | - * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation |
| 2 | + * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the Eclipse Public License 2.0 which is available at |
|
12 | 12 |
|
13 | 13 | import io.vertx.core.*; |
14 | 14 | import io.vertx.core.buffer.Buffer; |
15 | | -import io.vertx.core.impl.ContextInternal; |
16 | 15 | import io.vertx.oracleclient.OracleException; |
17 | 16 | import io.vertx.sqlclient.Tuple; |
18 | 17 | import oracle.sql.TIMESTAMPTZ; |
19 | 18 |
|
20 | 19 | import java.sql.*; |
21 | | -import java.util.ArrayList; |
22 | | -import java.util.List; |
23 | | -import java.util.concurrent.Flow; |
24 | 20 | import java.util.function.Function; |
25 | 21 | import java.util.function.Supplier; |
26 | 22 |
|
27 | | -import static io.vertx.oracleclient.impl.FailureUtil.sanitize; |
28 | | - |
29 | 23 | public class Helper { |
30 | 24 |
|
31 | 25 | public static void closeQuietly(AutoCloseable autoCloseable) { |
@@ -78,66 +72,6 @@ public static void runOrHandleSQLException(ThrowingRunnable runnable) |
78 | 72 | } |
79 | 73 | } |
80 | 74 |
|
81 | | - public static <T> Future<T> first(Flow.Publisher<T> publisher, ContextInternal context) { |
82 | | - Promise<T> promise = context.promise(); |
83 | | - publisher.subscribe(new Flow.Subscriber<>() { |
84 | | - volatile Flow.Subscription subscription; |
85 | | - |
86 | | - @Override |
87 | | - public void onSubscribe(Flow.Subscription subscription) { |
88 | | - this.subscription = subscription; |
89 | | - subscription.request(1); |
90 | | - } |
91 | | - |
92 | | - @Override |
93 | | - public void onNext(T item) { |
94 | | - context.runOnContext(x -> promise.tryComplete(item)); |
95 | | - subscription.cancel(); |
96 | | - } |
97 | | - |
98 | | - @Override |
99 | | - public void onError(Throwable throwable) { |
100 | | - promise.fail(sanitize(throwable)); |
101 | | - } |
102 | | - |
103 | | - @Override |
104 | | - public void onComplete() { |
105 | | - // Use tryComplete as the completion signal can be sent even if we cancelled. |
106 | | - // Also for Publisher<Void> we would get in this case. |
107 | | - promise.tryComplete(null); |
108 | | - } |
109 | | - }); |
110 | | - return promise.future(); |
111 | | - } |
112 | | - |
113 | | - public static <T> Future<List<T>> collect(Flow.Publisher<T> publisher, ContextInternal context) { |
114 | | - Promise<List<T>> promise = context.promise(); |
115 | | - publisher.subscribe(new Flow.Subscriber<>() { |
116 | | - final List<T> list = new ArrayList<>(); |
117 | | - |
118 | | - @Override |
119 | | - public void onSubscribe(Flow.Subscription subscription) { |
120 | | - subscription.request(Long.MAX_VALUE); |
121 | | - } |
122 | | - |
123 | | - @Override |
124 | | - public void onNext(T item) { |
125 | | - list.add(item); |
126 | | - } |
127 | | - |
128 | | - @Override |
129 | | - public void onError(Throwable throwable) { |
130 | | - promise.fail(sanitize(throwable)); |
131 | | - } |
132 | | - |
133 | | - @Override |
134 | | - public void onComplete() { |
135 | | - promise.complete(list); |
136 | | - } |
137 | | - }); |
138 | | - return promise.future(); |
139 | | - } |
140 | | - |
141 | 75 | public static Object convertSqlValue(Object value) throws SQLException { |
142 | 76 | if (value == null) { |
143 | 77 | return null; |
|
0 commit comments