Skip to content

Commit

Permalink
JDK8兼容性调整
Browse files Browse the repository at this point in the history
  • Loading branch information
oldmanpushcart committed Dec 27, 2024
1 parent 776d38a commit 026c4bd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private TranscriptionRequest(Builder builder) {

@Override
protected Object input() {
return new HashMap<>() {{
return new HashMap<String, Object>() {{
put("file_urls", resources);
}};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Collection;
import java.util.concurrent.CompletionStage;

import static io.github.oldmanpushcart.dashscope4j.util.CompletableFutureUtils.thenIterateCompose;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.thenIterateCompose;
import static java.util.concurrent.CompletableFuture.completedFuture;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.net.URI;
import java.util.concurrent.CompletionStage;

import static io.github.oldmanpushcart.dashscope4j.util.CompletableFutureUtils.thenIterateCompose;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.thenIterateCompose;
import static java.util.concurrent.CompletableFuture.completedFuture;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.concurrent.CompletionStage;

import static io.github.oldmanpushcart.dashscope4j.util.CompletableFutureUtils.thenIterateCompose;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.thenIterateCompose;
import static java.util.concurrent.CompletableFuture.completedFuture;

class ProcessTranscriptionForUploadInterceptor implements Interceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import java.util.function.Function;

import static io.github.oldmanpushcart.dashscope4j.internal.InternalContents.*;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.failedStage;
import static java.util.Objects.isNull;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.CompletableFuture.failedFuture;

@Slf4j
public class ApiOpImpl implements ApiOp {
Expand Down Expand Up @@ -257,7 +257,8 @@ private CompletionStage<TaskGetResponse> _rollingTask(TaskGetRequest taskGetRequ
}

if (!task.isCancelable()) {
return failedFuture(ex);

return failedStage(ex);
}

final TaskCancelRequest taskCancelRequest = TaskCancelRequest.newBuilder()
Expand All @@ -268,7 +269,7 @@ private CompletionStage<TaskGetResponse> _rollingTask(TaskGetRequest taskGetRequ
log.warn("dashscope://task/cancel completed: task={};", task.identity(), cex);
return cv;
})
.thenCompose(cv -> failedFuture(ex));
.thenCompose(cv -> failedStage(ex));

})
.thenCompose(f -> f)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.oldmanpushcart.dashscope4j.util;
package io.github.oldmanpushcart.dashscope4j.internal.util;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -15,6 +15,12 @@
*/
public class CompletableFutureUtils {

public static <T> CompletionStage<T> failedStage(Throwable ex) {
final CompletableFuture<T> future = new CompletableFuture<>();
future.completeExceptionally(ex);
return future;
}

/**
* 解包异常
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.stream.Collectors;

import static io.github.oldmanpushcart.dashscope4j.api.ApiAssertions.assertApiResponseSuccessful;
import static io.github.oldmanpushcart.dashscope4j.util.CompletableFutureUtils.unwrapEx;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.unwrapEx;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.concurrent.ExecutionException;

import static io.github.oldmanpushcart.dashscope4j.api.ApiAssertions.assertApiResponseSuccessful;
import static io.github.oldmanpushcart.dashscope4j.util.CompletableFutureUtils.unwrapEx;
import static io.github.oldmanpushcart.dashscope4j.internal.util.CompletableFutureUtils.unwrapEx;

public class GenImageTestCase extends ClientSupport {

Expand Down

0 comments on commit 026c4bd

Please sign in to comment.