Example usage for org.springframework.http.client ClientHttpRequest getClass

List of usage examples for org.springframework.http.client ClientHttpRequest getClass

Introduction

In this page you can find the example usage for org.springframework.http.client ClientHttpRequest getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.tasktop.c2c.server.common.service.tests.http.MultiUserClientHttpRequestFactoryTest.java

private HttpClient getHttpClient(ClientHttpRequest request) {
    Class<?> clazz = request.getClass();
    while (clazz != Object.class) {
        for (Field field : clazz.getDeclaredFields()) {
            if (HttpClient.class.isAssignableFrom(field.getType())) {
                field.setAccessible(true);
                try {
                    return (HttpClient) field.get(request);
                } catch (Exception e) {
                    throw new IllegalStateException(e);
                }// w  w  w  .  j av a  2 s . c  o  m
            }
        }
        clazz = clazz.getSuperclass();
    }
    throw new IllegalStateException();
}