Skip to content

Fix NPE in emoji filter and enforce Locale.ROOT for case folding#102

Closed
Copilot wants to merge 2 commits intobolt-performance-emoji-optimization-10389537235408575973from
copilot/sub-pr-99
Closed

Fix NPE in emoji filter and enforce Locale.ROOT for case folding#102
Copilot wants to merge 2 commits intobolt-performance-emoji-optimization-10389537235408575973from
copilot/sub-pr-99

Conversation

Copy link

Copilot AI commented Feb 27, 2026

performFiltering called charSequence.toString() before the null check, risking an NPE on framework-initiated filter calls with a null constraint. Additionally, toLowerCase() without a locale was used in both the filter and getLowerShortcode(), making matching locale-sensitive.

Changes

  • CustomEmojiPopupKeyboard.javaperformFiltering

    • Moved null/empty guard before charSequence.toString(); search is now computed only inside the else branch
    • Switched to toLowerCase(Locale.ROOT)
    • Added import java.util.Locale
  • Emoji.javagetLowerShortcode()

    • Switched cached value to shortcode.toLowerCase(Locale.ROOT) so both sides of the contains() check use the same locale
    • Added import java.util.Locale
// Before — NPE if charSequence is null
String search = charSequence.toString().toLowerCase().trim();
if (charSequence == null || charSequence.length() == 0) { ... }

// After — null-safe, locale-invariant
if (charSequence == null || charSequence.length() == 0) {
    filteredEmoji.addAll(originalCategory.emojis);
} else {
    String search = charSequence.toString().toLowerCase(Locale.ROOT).trim();
    ...
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dlukt <201112286+dlukt@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/lib/gradle-daemon-main-8.11.1.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Optimize emoji search allocation in CustomEmojiPopupKeyboard Fix NPE in emoji filter and enforce Locale.ROOT for case folding Feb 27, 2026
@dlukt dlukt closed this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants