Avoid recursive language defaults in LangUtil to prevent StackOverflow #4

Merged
NotAlexNoyle merged 1 commits from codex/fix-stack-overflow-errors-in-plugin into main 2026-03-09 04:25:18 -04:00
NotAlexNoyle commented 2026-03-09 04:25:06 -04:00 (Migrated from github.com)

Motivation

  • Prevent a StackOverflowError originating from Bukkit's MemorySection#get/getDefault recursion when the English language file was configured to use itself as defaults.

Description

  • Modify LangUtil so selectedLangDefaults.setDefaults(englishDefaults) is only applied when the resolved language is not EN_US, avoiding a self-referential defaults chain.
  • Preserve existing behavior for custom override language files by continuing to call messages.setDefaults(selectedLangDefaults) when an override file exists.
  • Change made in src/main/java/com/tcoded/playerbountiesplus/util/LangUtil.java.

Testing

  • Ran ./gradlew test, which failed in this environment due to a Gradle/JDK setup error (25.0.1), so automated test suite could not be completed successfully.

Codex Task

### Motivation - Prevent a `StackOverflowError` originating from Bukkit's `MemorySection#get/getDefault` recursion when the English language file was configured to use itself as defaults. ### Description - Modify `LangUtil` so `selectedLangDefaults.setDefaults(englishDefaults)` is only applied when the resolved language is not `EN_US`, avoiding a self-referential defaults chain. - Preserve existing behavior for custom override language files by continuing to call `messages.setDefaults(selectedLangDefaults)` when an override file exists. - Change made in `src/main/java/com/tcoded/playerbountiesplus/util/LangUtil.java`. ### Testing - Ran `./gradlew test`, which failed in this environment due to a Gradle/JDK setup error (`25.0.1`), so automated test suite could not be completed successfully. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69ae830cce50832f864e6a69a86163df)
Sign in to join this conversation.