diff --git a/trunk/sqltoy-orm-core/pom.xml b/trunk/sqltoy-orm-core/pom.xml index d6fb7399b..d88844a70 100644 --- a/trunk/sqltoy-orm-core/pom.xml +++ b/trunk/sqltoy-orm-core/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.sagframe - 5.6.12.RC1 + 5.6.12 sagacity-sqltoy sqltoy core code sagacity-sqltoy @@ -14,13 +14,13 @@ 3.10.8 4.5.14 4.4.16 - 8.14.2 + 8.14.3 2.0.52 3.12.14 5.10.3 1.10.3 2.0.13 - 2.2.224 + 2.3.230 1.18.34 1.2.23 2.14.5 diff --git a/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/SqlExecuteStat.java b/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/SqlExecuteStat.java index 9e5566812..e458e70e2 100644 --- a/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/SqlExecuteStat.java +++ b/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/SqlExecuteStat.java @@ -344,6 +344,7 @@ public static String getFirstTrace() { || className.startsWith("com.sun.") || className.startsWith("org.springframework.") || className.startsWith("org.noear.solon."))) { traceElement = stackTraceElements[i + nextIndex]; + className = traceElement.getClassName(); nextIndex++; } } diff --git a/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/utils/HttpClientUtils.java b/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/utils/HttpClientUtils.java index 97dad2031..908a6f069 100644 --- a/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/utils/HttpClientUtils.java +++ b/trunk/sqltoy-orm-core/src/main/java/org/sagacity/sqltoy/utils/HttpClientUtils.java @@ -6,13 +6,13 @@ import java.util.Map; import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.BasicCredentialsProvider; @@ -69,6 +69,7 @@ public static String doPost(SqlToyContext sqltoyContext, final String url, Strin httpPost.setHeader("Connection", "close"); httpPost.setConfig(requestConfig); CloseableHttpClient client = null; + CloseableHttpResponse response = null; try { if (StringUtil.isNotBlank(username) && StringUtil.isNotBlank(password)) { // 凭据提供器 @@ -91,7 +92,7 @@ public static String doPost(SqlToyContext sqltoyContext, final String url, Strin ((UrlEncodedFormEntity) httpEntity).setContentType(CONTENT_TYPE); httpPost.setEntity(httpEntity); } - HttpResponse response = client.execute(httpPost); + response = client.execute(httpPost); // 返回结果 HttpEntity reponseEntity = response.getEntity(); if (reponseEntity != null) { @@ -99,6 +100,17 @@ public static String doPost(SqlToyContext sqltoyContext, final String url, Strin } } catch (Exception e) { throw e; + } finally { + try { + if (response != null) { + response.close(); + } + if (client != null) { + client.close(); + } + } catch (Exception e) { + + } } return null; } @@ -137,6 +149,7 @@ public static JSONObject doPost(SqlToyContext sqltoyContext, NoSqlConfigModel no String realUrl; // 返回结果 HttpEntity reponseEntity = null; + String result = null; // 使用elastic rest client(默认) if (esConfig.getRestClient() != null) { realUrl = wrapUrl(esConfig, nosqlConfig); @@ -146,17 +159,25 @@ public static JSONObject doPost(SqlToyContext sqltoyContext, NoSqlConfigModel no } // 默认采用post请求 RestClient restClient = null; + Response response; try { restClient = esConfig.getRestClient(); Request request = new Request(POST, realUrl); request.setEntity(httpEntity); - Response response = restClient.performRequest(request); + response = restClient.performRequest(request); reponseEntity = response.getEntity(); + if (reponseEntity != null) { + result = EntityUtils.toString(reponseEntity, nosqlConfig.getCharset()); + } } catch (Exception e) { throw e; } finally { - if (restClient != null) { - restClient.close(); + try { + if (restClient != null) { + restClient.close(); + } + } catch (Exception e) { + } } } // 组织httpclient模式调用(此种模式不推荐使用) @@ -180,6 +201,7 @@ public static JSONObject doPost(SqlToyContext sqltoyContext, NoSqlConfigModel no httpPost.setConfig(requestConfig); } CloseableHttpClient client = null; + CloseableHttpResponse response = null; try { if (StringUtil.isNotBlank(esConfig.getUsername()) && StringUtil.isNotBlank(esConfig.getPassword())) { // 凭据提供器 @@ -191,22 +213,32 @@ public static JSONObject doPost(SqlToyContext sqltoyContext, NoSqlConfigModel no } else { client = HttpClients.createDefault(); } - HttpResponse response = client.execute(httpPost); + response = client.execute(httpPost); reponseEntity = response.getEntity(); + if (reponseEntity != null) { + result = EntityUtils.toString(reponseEntity, nosqlConfig.getCharset()); + } } catch (Exception e) { throw e; - } - } - String result = null; - if (reponseEntity != null) { - result = EntityUtils.toString(reponseEntity, nosqlConfig.getCharset()); - if (sqltoyContext.isDebug()) { - logger.debug("result={}", result); + } finally { + try { + if (response != null) { + response.close(); + } + if (client != null) { + client.close(); + } + } catch (Exception e) { + + } } } if (StringUtil.isBlank(result)) { return null; } + if (sqltoyContext.isDebug()) { + logger.debug("result={}", result); + } // 将结果转换为JSON对象 JSONObject json = JSON.parseObject(result); // 存在错误 diff --git a/trunk/sqltoy-orm-solon-plugin/pom.xml b/trunk/sqltoy-orm-solon-plugin/pom.xml index fa702a1f4..420052110 100644 --- a/trunk/sqltoy-orm-solon-plugin/pom.xml +++ b/trunk/sqltoy-orm-solon-plugin/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.sagframe - 5.6.12.RC1 + 5.6.12 sagacity-sqltoy-solon-plugin sagacity-sqltoy-solon-plugin diff --git a/trunk/sqltoy-orm-spring-starter/pom.xml b/trunk/sqltoy-orm-spring-starter/pom.xml index 6dfcec411..5f034ea6f 100644 --- a/trunk/sqltoy-orm-spring-starter/pom.xml +++ b/trunk/sqltoy-orm-spring-starter/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.sagframe - 5.6.12.RC1 + 5.6.12 sagacity-sqltoy-spring-starter sagacity-sqltoy-spring-starter sqltoy springboot starter diff --git a/trunk/sqltoy-orm-spring/pom.xml b/trunk/sqltoy-orm-spring/pom.xml index 9b0716ea4..4b297f03c 100644 --- a/trunk/sqltoy-orm-spring/pom.xml +++ b/trunk/sqltoy-orm-spring/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.sagframe - 5.6.12.RC1 + 5.6.12 sagacity-sqltoy-spring sagacity-sqltoy-spring sagacity-sqltoy-spring