From 74d09a897ae9289746cdb312773e333afc99f3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Wed, 8 Mar 2023 12:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91JeroElasticsearchT?= =?UTF-8?q?emplate=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jero/common/es/JeroElasticsearchTemplate.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java index 8cc46d67..1c3563d3 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/es/JeroElasticsearchTemplate.java @@ -144,7 +144,7 @@ public class JeroElasticsearchTemplate { if (found) { return result.getJSONObject("_source"); } else { - return null; + return new JSONObject(); } } @@ -245,7 +245,7 @@ public class JeroElasticsearchTemplate { } catch (org.springframework.web.client.HttpClientErrorException e) { String message = e.getMessage(); if (message != null && message.contains("404 Not Found")) { - return null; + return new JSONObject(); } throw e; } @@ -380,7 +380,7 @@ public class JeroElasticsearchTemplate { data.remove("id"); bodySB.append(data.toJSONString()).append("\n"); } - System.out.println("+-+-+-: bodySB.toString(): " + bodySB.toString()); + log.info("+-+-+-: bodySB.toString(): " + bodySB.toString()); HttpHeaders headers = RestUtil.getHeaderApplicationJson(); RestUtil.request(url, HttpMethod.PUT, headers, null, bodySB, JSONObject.class); return true; @@ -481,7 +481,7 @@ public class JeroElasticsearchTemplate { */ public JSONObject buildQueryString(String field, String... args) { if (field == null) { - return null; + return new JSONObject(); } StringBuilder sb = new StringBuilder(field).append(":("); if (args != null) {