aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2018-03-08 17:49:12 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2018-03-08 17:49:16 +0800
commit722d78240f9ae320ceb262b496cf8cee07ae2591 (patch)
tree1461425421ff7ce4a995e24209525521c29b0b05 /src
parent342e59ba8f874e692fb508d975448e6d0abaf266 (diff)
Solve nexus IQ security issue
Upgrade the jackson-core to the latest version to solve SONATYPE-2017-0355 Issue-ID: MSB-131 Change-Id: I9a7fc431a07533c47fe56bd69b18012cf9d7216c Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java154
1 files changed, 76 insertions, 78 deletions
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
index 74096e7..085a35f 100644
--- a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
+++ b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
@@ -28,7 +28,7 @@ import org.onap.msb.sdk.httpclient.lb.LoadBalanceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jersey.repackaged.com.google.common.collect.Lists;
+import com.google.common.collect.Lists;
import retrofit2.Call;
/**
@@ -37,125 +37,123 @@ import retrofit2.Call;
*/
public class RetrofitServiceHandler implements InvocationHandler {
- private final static Logger logger = LoggerFactory.getLogger(RetrofitServiceHandler.class);
- private static long periodTime = 60;
+ private final static Logger logger = LoggerFactory.getLogger(RetrofitServiceHandler.class);
+ private static long periodTime = 60;
- static {
- try {
- String periodStr = System.getenv("retrofit_route_cache_refresh_period");
- periodTime = periodStr != null ? Long.valueOf(periodStr) : 60;
- logger.info("retrofit_route_cache_refresh_period:" + periodTime);
- } catch (Exception e) {
- logger.warn("", e);
- }
+ static {
+ try {
+ String periodStr = System.getenv("retrofit_route_cache_refresh_period");
+ periodTime = periodStr != null ? Long.valueOf(periodStr) : 60;
+ logger.info("retrofit_route_cache_refresh_period:" + periodTime);
+ } catch (Exception e) {
+ logger.warn("", e);
+ }
- }
+ }
- private RetrofitServiceHandlerContext flowContext;
+ private RetrofitServiceHandlerContext flowContext;
- private AtomicReference<Map<ServiceHttpEndPointObject, Object>> endPointToRetrofitRef =
- new AtomicReference();
+ private AtomicReference<Map<ServiceHttpEndPointObject, Object>> endPointToRetrofitRef = new AtomicReference();
- public RetrofitServiceHandler(RetrofitServiceHandlerContext flowContext) {
- super();
- this.flowContext = flowContext;
- logger.info("retrofit_route_cache_refresh_period:" + periodTime);
- }
+ public RetrofitServiceHandler(RetrofitServiceHandlerContext flowContext) {
+ super();
+ this.flowContext = flowContext;
+ logger.info("retrofit_route_cache_refresh_period:" + periodTime);
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method,
- * java.lang.Object[])
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method,
+ * java.lang.Object[])
+ */
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- Object retrofitObject = null;
- ServiceHttpEndPointObjectWapper wapper = null;
+ Object retrofitObject = null;
+ ServiceHttpEndPointObjectWapper wapper = null;
- updateMsbInfo();
- wapper = selectRetrofitObjectByLBStrategy(
- flowContext.getRetrofitObjectBuilder().buildRetrofitObject(endPointToRetrofitRef, null),
- method, args);
- retrofitObject = wapper.retrofitObject;
+ updateMsbInfo();
+ wapper = selectRetrofitObjectByLBStrategy(
+ flowContext.getRetrofitObjectBuilder().buildRetrofitObject(endPointToRetrofitRef, null), method,
+ args);
+ retrofitObject = wapper.retrofitObject;
- Object resultObjecct = method.invoke(retrofitObject, args);
+ Object resultObjecct = method.invoke(retrofitObject, args);
- if (resultObjecct instanceof Call) {
- Call targetCall = (Call) resultObjecct;
- return new ProxyRetrofitCall(targetCall, this, wapper.endPoint, proxy, method, args);
+ if (resultObjecct instanceof Call) {
+ Call targetCall = (Call) resultObjecct;
+ return new ProxyRetrofitCall(targetCall, this, wapper.endPoint, proxy, method, args);
+ }
+ return resultObjecct;
}
- return resultObjecct;
- }
- public Object reInvoke(Object proxy, Method method, Object[] args,
- ServiceHttpEndPointObject endPoint) throws Throwable {
+ public Object reInvoke(Object proxy, Method method, Object[] args, ServiceHttpEndPointObject endPoint)
+ throws Throwable {
- Object retrofitObject = null;
- ServiceHttpEndPointObjectWapper wapper = null;
+ Object retrofitObject = null;
+ ServiceHttpEndPointObjectWapper wapper = null;
- updateMsbInfo();
+ updateMsbInfo();
- Map<ServiceHttpEndPointObject, Object> serviceHttpEndPointObjectMap =
- flowContext.getRetrofitObjectBuilder().buildRetrofitObject(endPointToRetrofitRef, endPoint);
+ Map<ServiceHttpEndPointObject, Object> serviceHttpEndPointObjectMap =
+ flowContext.getRetrofitObjectBuilder().buildRetrofitObject(endPointToRetrofitRef, endPoint);
- wapper = selectRetrofitObjectByLBStrategy(serviceHttpEndPointObjectMap, method, args);
+ wapper = selectRetrofitObjectByLBStrategy(serviceHttpEndPointObjectMap, method, args);
- retrofitObject = wapper.retrofitObject;
+ retrofitObject = wapper.retrofitObject;
- Object resultObjecct = method.invoke(retrofitObject, args);
+ Object resultObjecct = method.invoke(retrofitObject, args);
- return resultObjecct;
+ return resultObjecct;
- }
+ }
- private void updateMsbInfo() {
+ private void updateMsbInfo() {
- if (System.currentTimeMillis() - flowContext.getLastUpdateMsbTime() > periodTime * 1000) {
- clean();
+ if (System.currentTimeMillis() - flowContext.getLastUpdateMsbTime() > periodTime * 1000) {
+ clean();
+ }
}
- }
- public void clean() {
- endPointToRetrofitRef.set(null);
- }
+ public void clean() {
+ endPointToRetrofitRef.set(null);
+ }
- private ServiceHttpEndPointObjectWapper selectRetrofitObjectByLBStrategy(
- Map<ServiceHttpEndPointObject, Object> srvEndPointToRetrofit, Method method, Object[] args)
- throws RetrofitServiceRuntimeException {
+ private ServiceHttpEndPointObjectWapper selectRetrofitObjectByLBStrategy(
+ Map<ServiceHttpEndPointObject, Object> srvEndPointToRetrofit, Method method, Object[] args)
+ throws RetrofitServiceRuntimeException {
- LoadBalanceContext ctx = new LoadBalanceContext();
- ctx.setEndPoints(Lists.newArrayList(srvEndPointToRetrofit.keySet()));
- ctx.setArgs(args);
- ctx.setMethod(method);
- ServiceHttpEndPointObject endPoint = flowContext.getLbStrategy().chooseEndPointObject(ctx);
- return new ServiceHttpEndPointObjectWapper(endPoint, srvEndPointToRetrofit.get(endPoint));
- }
+ LoadBalanceContext ctx = new LoadBalanceContext();
+ ctx.setEndPoints(Lists.newArrayList(srvEndPointToRetrofit.keySet()));
+ ctx.setArgs(args);
+ ctx.setMethod(method);
+ ServiceHttpEndPointObject endPoint = flowContext.getLbStrategy().chooseEndPointObject(ctx);
+ return new ServiceHttpEndPointObjectWapper(endPoint, srvEndPointToRetrofit.get(endPoint));
+ }
}
class ServiceHttpEndPointObjectWapper {
- protected ServiceHttpEndPointObject endPoint;
- protected Object retrofitObject;
+ protected ServiceHttpEndPointObject endPoint;
+ protected Object retrofitObject;
- public ServiceHttpEndPointObjectWapper(ServiceHttpEndPointObject endPoint,
- Object retrofitObject) {
- super();
- this.endPoint = endPoint;
- this.retrofitObject = retrofitObject;
- }
+ public ServiceHttpEndPointObjectWapper(ServiceHttpEndPointObject endPoint, Object retrofitObject) {
+ super();
+ this.endPoint = endPoint;
+ this.retrofitObject = retrofitObject;
+ }
}