java:S1166 Either log or rethrow this exception

  • Version: Enterprise Edition - Version 9.9.1
  • Docker

I’m reaching out regarding a SonarQube issue flagged in our codebase under rule java:S1166“Either log or rethrow this exception.” The warning appears in a block where we are already logging the exception using log.error(...), yet the rule still marks it as a code smell.

Could you help clarify why this rule is triggered even though the exception is being logged? Is there an additional requirement, such as rethrowing the exception or preserving the stack trace differently, that we might be missing?

public ReTriggerEventResponse reTriggerEvent(ReTriggerEventRequest reTriggerEventRequest) {
        List<String> succeedList = new ArrayList<>();
        List<String> failedList = new ArrayList<>();
        Optional.ofNullable(reTriggerEventRequest)
                .map(ReTriggerEventRequest::getReTriggerEventList)
                .orElse(Collections.emptyList())
                .forEach(s -> {
                    try {
                        dataMaintenanceAdminV3Mapper.insertSysOutBoxById(UUID.fromString(UuidUtil.uuidAddHyphen(s)));
                        succeedList.add(s);
                        log.info("[reTriggerEvent] re-trigger event {} succeed ", s);
                    } catch (RuntimeException e) {
			// Either log or rethrow this exception
                        failedList.add(s);
                        log.error("[reTriggerEvent] fail to re-trigger event: {}", s, e);
                    }
                });
        return ReTriggerEventResponse.builder().succeedList(succeedList).failedList(failedList).build();
    }

Hi,

Welcome to the community!

Your version is past EOL. You should update to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your update path is:

9.9.1 → 2025.1.4 → 2025.6 (last step optional)

Note that the next LTA, 2026.1 is imminent. You should start your upgrade journey as soon as possible.

You may find these resources helpful:

If you have questions about updating, feel free to open a new thread for that here.

If your error persists after update, please come back to us.

 
HTH,
Ann