public static Exception getCause(BuiltResponse resp) { if (resp == null || resp.getStatus() != Status.EXPECTATION_FAILED.getStatusCode()) return null; String exceptionClass = resp.getHeaderString(EXCEPTION_HEADER); if (!StringUtils.isBlank(exceptionClass)) { String body = resp.readEntity(String.class); resp.close(); try { ByteArrayInputStream bais = new ByteArrayInputStream( Base64.decode(body.getBytes(MotanConstants.DEFAULT_CHARACTER))); ObjectInputStream ois = new ObjectInputStream(bais); return (Exception) ois.readObject(); } catch (Exception e) { LoggerUtil.error("deserialize " + exceptionClass + " error", e); } } return null; }
@Override public <T> T readEntity(Class<T> type, Annotation[] annotations) { return readEntity(type, null, annotations); }
@Override public <T> T readEntity(Class<T> type) { return readEntity(type, null, null); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), null); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), annotations); }
@Override public <T> T readEntity(Class<T> type) { return readEntity(type, null, null); }
@Override public <T> T readEntity(Class<T> type, Annotation[] annotations) { return readEntity(type, null, annotations); }
@Override public <T> T readEntity(Class<T> type) { return readEntity(type, null, null); }
@Override public <T> T readEntity(Class<T> type, Annotation[] annotations) { return readEntity(type, null, annotations); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), null); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), annotations); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), annotations); }
@SuppressWarnings(value = "unchecked") @Override public <T> T readEntity(GenericType<T> entityType) { return readEntity((Class<T>) entityType.getRawType(), entityType.getType(), null); }