1 /*******************************************************************************
2 * Copyright 2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
13 ******************************************************************************/
15 * Copyright (C) 2015 Square, Inc.
17 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
18 * in compliance with the License. You may obtain a copy of the License at
20 * http://www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software distributed under the License
23 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
24 * or implied. See the License for the specific language governing permissions and limitations under
27 package org.onap.msb.sdk.httpclient.convert.jackson;
29 import java.io.IOException;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import com.fasterxml.jackson.databind.ObjectReader;
36 import okhttp3.ResponseBody;
37 import retrofit2.Converter;
39 final class JacksonResponseBodyConverter<T> implements Converter<ResponseBody, T> {
41 private static final Logger logger = LoggerFactory.getLogger(JacksonResponseBodyConverter.class);
43 private final ObjectReader adapter;
47 JacksonResponseBodyConverter(ObjectReader adapter) {
48 this.adapter = adapter;
52 public T convert(ResponseBody value) throws IOException {
56 return adapter.readValue(src);
57 } catch (IOException e) {
58 logger.error("parse responseBody error,body:" + src);