Skip to content

Commit

Permalink
Merge branch 'dev' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
chenrenfei committed Jul 18, 2024
2 parents d8b8ecc + 931715a commit 3450261
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 19 deletions.
6 changes: 3 additions & 3 deletions trunk/sqltoy-orm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.12.RC1</version>
<version>5.6.12</version>
<name>sagacity-sqltoy</name>
<description>sqltoy core code</description>
<artifactId>sagacity-sqltoy</artifactId>
Expand All @@ -14,13 +14,13 @@
<ehcache.version>3.10.8</ehcache.version>
<httpclient.version>4.5.14</httpclient.version>
<httpclient-core.version>4.4.16</httpclient-core.version>
<elastic-rest-client.version>8.14.2</elastic-rest-client.version>
<elastic-rest-client.version>8.14.3</elastic-rest-client.version>
<fastjson.version>2.0.52</fastjson.version>
<mongo.version>3.12.14</mongo.version>
<junit-jupiter.version>5.10.3</junit-jupiter.version>
<junit-platform.version>1.10.3</junit-platform.version>
<slf4j.version>2.0.13</slf4j.version>
<h2.version>2.2.224</h2.version>
<h2.version>2.3.230</h2.version>
<lombok.version>1.18.34</lombok.version>
<druid.version>1.2.23</druid.version>
<transmittable-thread-local>2.14.5</transmittable-thread-local>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
// 凭据提供器
Expand All @@ -91,14 +92,25 @@ 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) {
return EntityUtils.toString(reponseEntity, CHARSET);
}
} catch (Exception e) {
throw e;
} finally {
try {
if (response != null) {
response.close();
}
if (client != null) {
client.close();
}
} catch (Exception e) {

}
}
return null;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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模式调用(此种模式不推荐使用)
Expand All @@ -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())) {
// 凭据提供器
Expand All @@ -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);
// 存在错误
Expand Down
2 changes: 1 addition & 1 deletion trunk/sqltoy-orm-solon-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.sagframe</groupId>
<version>5.6.12.RC1</version>
<version>5.6.12</version>

<artifactId>sagacity-sqltoy-solon-plugin</artifactId>
<name>sagacity-sqltoy-solon-plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion trunk/sqltoy-orm-spring-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.12.RC1</version>
<version>5.6.12</version>
<name>sagacity-sqltoy-spring-starter</name>
<artifactId>sagacity-sqltoy-spring-starter</artifactId>
<description>sqltoy springboot starter</description>
Expand Down
2 changes: 1 addition & 1 deletion trunk/sqltoy-orm-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.12.RC1</version>
<version>5.6.12</version>
<name>sagacity-sqltoy-spring</name>
<description>sagacity-sqltoy-spring</description>
<artifactId>sagacity-sqltoy-spring</artifactId>
Expand Down

0 comments on commit 3450261

Please sign in to comment.