Copilot commented on code in PR #7104:
URL: https://github.com/apache/shenyu/pull/7104#discussion_r4045124308


##########
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java:
##########
@@ -140,7 +140,7 @@ public boolean existsIndex(final String indexName) {
         } catch (Exception e) {
             LogUtils.error(LOG, "fail to check the index exists, error:", e);
         }
-        return true;
+        return false;

Review Comment:
   Returning `false` for an uncertain check makes `consume0` call `createIndex` 
even when the index already exists. The Elasticsearch client surfaces the 
resulting `resource_already_exists_exception` as a runtime 
`ElasticsearchException`, while `createIndex` only catches `IOException`; that 
exception escapes before the bulk call, so a transient `exists` failure can 
still drop the batch. Make the create path idempotent by treating only the 
already-exists response as success (or otherwise handle it before returning to 
`consume0`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to