[#2581] Deprecate fetchLater() and FutureResult<R>
This commit is contained in:
parent
2256a01d62
commit
297db8be93
@ -68,8 +68,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@ -1479,47 +1477,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
catch (NoRecordMapperAvailableException expected) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchLater() throws Exception {
|
||||
Future<Result<B>> later;
|
||||
Result<B> result;
|
||||
|
||||
int activeCount = Thread.activeCount();
|
||||
|
||||
later = create().selectFrom(TBook()).orderBy(TBook_ID()).fetchLater();
|
||||
|
||||
// That's too fast for the query to be done, mostly
|
||||
assertFalse(later.isDone());
|
||||
assertFalse(later.isCancelled());
|
||||
assertEquals(activeCount + 1, Thread.activeCount());
|
||||
|
||||
// Get should make sure the internal thread is terminated
|
||||
result = later.get();
|
||||
Thread.sleep(500);
|
||||
assertEquals(activeCount, Thread.activeCount());
|
||||
|
||||
// Subsequent gets are ok
|
||||
result = later.get();
|
||||
result = later.get(1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
// Check the data
|
||||
assertEquals(4, result.size());
|
||||
assertEquals(BOOK_IDS, result.getValues(TBook_ID()));
|
||||
|
||||
// Start new threads
|
||||
later = create().selectFrom(TBook()).orderBy(TBook_ID()).fetchLater();
|
||||
later = create().selectFrom(TBook()).orderBy(TBook_ID()).fetchLater();
|
||||
later = create().selectFrom(TBook()).orderBy(TBook_ID()).fetchLater();
|
||||
assertEquals(activeCount + 3, Thread.activeCount());
|
||||
|
||||
// This should be enough to ensure that GC will collect finished threads
|
||||
later = null;
|
||||
System.gc();
|
||||
System.gc();
|
||||
Thread.sleep(500);
|
||||
assertEquals(activeCount, Thread.activeCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchResultSet() throws Exception {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
@ -65,7 +65,6 @@ import org.jooq.Condition;
|
||||
import org.jooq.Cursor;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FutureResult;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record1;
|
||||
@ -490,12 +489,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
|
||||
assertEquals(1, (int) count[0]);
|
||||
|
||||
FutureResult<Record> fetch9 = q.fetchLater();
|
||||
Thread.sleep(50);
|
||||
assertTrue(fetch9.isDone());
|
||||
assertEquals(1, fetch9.get().size());
|
||||
assertEquals("10", fetch9.get().getValue(0, 0));
|
||||
|
||||
Cursor<Record> fetch10 = q.fetchLazy();
|
||||
assertFalse(fetch10.isClosed());
|
||||
assertTrue(fetch10.hasNext());
|
||||
|
||||
@ -1474,11 +1474,6 @@ public abstract class jOOQAbstractTest<
|
||||
new FetchTests(this).testFetchIntoWithRecordMapperProvider();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchLater() throws Exception {
|
||||
new FetchTests(this).testFetchLater();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecordOriginals() throws Exception {
|
||||
new RecordTests(this).testRecordOriginals();
|
||||
|
||||
@ -816,10 +816,6 @@ public interface DSLContext {
|
||||
* <td> {@link ResultQuery#fetchInto(RecordHandler)}</td>
|
||||
* <td>Fetch records into a custom callback (similar to Spring's RowMapper)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link ResultQuery#fetchLater()}</td>
|
||||
* <td>Fetch records of a long-running query asynchronously</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
@ -866,10 +862,6 @@ public interface DSLContext {
|
||||
* <td> {@link ResultQuery#fetchInto(RecordHandler)}</td>
|
||||
* <td>Fetch records into a custom callback (similar to Spring's RowMapper)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link ResultQuery#fetchLater()}</td>
|
||||
* <td>Fetch records of a long-running query asynchronously</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
|
||||
@ -51,7 +51,10 @@ import java.util.concurrent.Future;
|
||||
* all data into a single report</li>
|
||||
* <li>...</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated - 3.2.0 - [#2581] - This type will be removed in jOOQ 4.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface FutureResult<R extends Record> extends Future<Result<R>> {
|
||||
|
||||
}
|
||||
|
||||
@ -932,7 +932,9 @@ public interface ResultQuery<R extends Record> extends Query {
|
||||
*
|
||||
* @return A future result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @deprecated - 3.2.0 - [#2581] - This method will be removed in jOOQ 4.0
|
||||
*/
|
||||
@Deprecated
|
||||
FutureResult<R> fetchLater() throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -961,7 +963,9 @@ public interface ResultQuery<R extends Record> extends Query {
|
||||
* @param executor A custom executor
|
||||
* @return A future result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @deprecated - 3.2.0 - [#2581] - This method will be removed in jOOQ 4.0
|
||||
*/
|
||||
@Deprecated
|
||||
FutureResult<R> fetchLater(ExecutorService executor) throws DataAccessException;
|
||||
|
||||
/**
|
||||
|
||||
@ -61,7 +61,6 @@ import org.jooq.Cursor;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FutureResult;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordHandler;
|
||||
import org.jooq.RecordMapper;
|
||||
@ -630,14 +629,16 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FutureResult<R> fetchLater() {
|
||||
@Deprecated
|
||||
public final org.jooq.FutureResult<R> fetchLater() {
|
||||
ExecutorService executor = newSingleThreadExecutor();
|
||||
Future<Result<R>> future = executor.submit(new ResultQueryCallable());
|
||||
return new FutureResultImpl<R>(future, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FutureResult<R> fetchLater(ExecutorService executor) {
|
||||
@Deprecated
|
||||
public final org.jooq.FutureResult<R> fetchLater(ExecutorService executor) {
|
||||
Future<Result<R>> future = executor.submit(new ResultQueryCallable());
|
||||
return new FutureResultImpl<R>(future);
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ import org.jooq.Result;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@Deprecated
|
||||
class FutureResultImpl<R extends Record> implements FutureResult<R> {
|
||||
|
||||
private final Future<Result<R>> future;
|
||||
|
||||
@ -53,7 +53,6 @@ import org.jooq.Converter;
|
||||
import org.jooq.Cursor;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.ForeignKey;
|
||||
import org.jooq.FutureResult;
|
||||
import org.jooq.GroupField;
|
||||
import org.jooq.JoinType;
|
||||
import org.jooq.Operator;
|
||||
@ -1290,12 +1289,14 @@ class SelectImpl<R extends Record> extends AbstractDelegatingQuery<Select<R>> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FutureResult<R> fetchLater() {
|
||||
@Deprecated
|
||||
public final org.jooq.FutureResult<R> fetchLater() {
|
||||
return getDelegate().fetchLater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FutureResult<R> fetchLater(ExecutorService executor) {
|
||||
@Deprecated
|
||||
public final org.jooq.FutureResult<R> fetchLater(ExecutorService executor) {
|
||||
return getDelegate().fetchLater(executor);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user