1.微信支付修复部分jdk无法加载证书问题

2.微信下载对账单报无法类型转换问题
3.微信退款非必填参数忽略
This commit is contained in:
egzosn
2021-11-20 23:49:58 +08:00
parent e4ca2a0e7d
commit 6ab618ca44
11 changed files with 76 additions and 60 deletions

View File

@@ -317,6 +317,38 @@ public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase impleme
* @throws IOException 响应类型文本转换时抛出异常
*/
private T toBean(HttpEntity entity, String[] contentType) throws IOException {
//是否为 输入流
if (InputStream.class.isAssignableFrom(responseType)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
entity.writeTo(os);
return (T) new ByteArrayInputStream(os.toByteArray());
}
//是否为 字节数数组
if (byte[].class.isAssignableFrom(responseType)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
entity.writeTo(os);
return (T) os.toByteArray();
}
//输出流
if (OutputStream.class.isAssignableFrom(responseType)) {
try {
OutputStream t;
if (responseType == OutputStream.class){
t= new ByteArrayOutputStream();
}else {
t = (OutputStream) responseType.newInstance();
}
entity.writeTo( t);
return (T) t;
} catch (InstantiationException e) {
throw new PayErrorException(new PayException("InstantiationException", e.getMessage()));
} catch (IllegalAccessException e) {
throw new PayErrorException(new PayException("IllegalAccessException", e.getMessage()));
}
}
//判断内容类型是否为文本类型
if (isText(contentType[0])) {
/* String charset = "UTF-8";
@@ -359,35 +391,6 @@ public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase impleme
throw new PayErrorException(new PayException("failure", "类型转化异常,contentType:" + entity.getContentType().getValue(), result));
}
//是否为 输入流
if (InputStream.class.isAssignableFrom(responseType)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
entity.writeTo(os);
return (T) new ByteArrayInputStream(os.toByteArray());
}
//是否为 字节数数组
if (byte[].class.isAssignableFrom(responseType)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
entity.writeTo(os);
return (T) os.toByteArray();
}
//输出流
if (OutputStream.class.isAssignableFrom(responseType)) {
try {
OutputStream t;
if (responseType == OutputStream.class){
t= new ByteArrayOutputStream();
}else {
t = (OutputStream) responseType.newInstance();
}
entity.writeTo( t);
return (T) t;
} catch (InstantiationException e) {
throw new PayErrorException(new PayException("InstantiationException", e.getMessage()));
} catch (IllegalAccessException e) {
throw new PayErrorException(new PayException("IllegalAccessException", e.getMessage()));
}
}
throw new PayErrorException(new PayException("failure", "类型转化异常,contentType:" + entity.getContentType().getValue()));
}