Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestProxy: Removing code that reflect on OperationStatus type in unreleased management-core #7840

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.azure.core.util.FluxUtil;
import com.azure.core.implementation.TypeUtil;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.IOException;
Expand Down Expand Up @@ -375,38 +374,13 @@ private static Object convertToResultType(Object wireResponse, Type resultType,
*/
private static Type extractEntityTypeFromReturnType(HttpResponseDecodeData decodeData) {
Type token = decodeData.getReturnType();
final ClientLogger logger = new ClientLogger(HttpResponseBodyDecoder.class);
if (token != null) {
if (TypeUtil.isTypeOrSubTypeOf(token, Mono.class)) {
token = TypeUtil.getTypeArgument(token);
} else if (TypeUtil.isTypeOrSubTypeOf(token, Flux.class)) {
Type t = TypeUtil.getTypeArgument(token);
try {
// TODO: anuchan - unwrap OperationStatus a different way
// Check for OperationStatus<?>
if (TypeUtil.isTypeOrSubTypeOf(t, Class.forName(
"com.azure.core.management.implementation.OperationStatus"))) {
token = t;
}
} catch (ClassNotFoundException ignored) {
logger.warning("Failed to find class 'com.azure.core.management.implementation.OperationStatus'.");
}
}

if (TypeUtil.isTypeOrSubTypeOf(token, Response.class)) {
token = TypeUtil.getRestResponseBodyType(token);
}

try {
// TODO: anuchan - unwrap OperationStatus a different way
if (TypeUtil.isTypeOrSubTypeOf(token, Class.forName(
"com.azure.core.management.implementation.OperationStatus"))) {
// Get Type of 'T' from OperationStatus<T>
token = TypeUtil.getTypeArgument(token);
}
} catch (ClassNotFoundException ignored) {
logger.warning("Failed to find class 'com.azure.core.management.implementation.OperationStatus'.");
}
}
return token;
}
Expand Down