Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tests in apple silicon and fix NPE in BaseLogStorageTest #1182

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 18, 2025

I tried to run the project tests for the first time, but they failed. I found 2 reasons and fixed them:
1 - jna.version = 5.5.0 does not support Apple Silicon processors. So I upgraded the version to 5.7.0
2 - BaseLogStorageTest#testTruncatePrefix test failed, it failed with NullPointerException inside ThreadPoolsFactory#runInThread method when accessing ConcurrentHashMap with key == null. To fix this, I added a method to call LogStorageOptions.setGroupId("test"); before running the tests.

Summary by CodeRabbit

  • Chores

    • Updated the project’s parent version to 1.3.16 across multiple modules.
    • Upgraded the primary native dependency to version 5.7.0 for enhanced compatibility.
  • Tests

    • Refined log storage test configuration by setting an explicit group identifier for improved test clarity.

Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request updates various Maven POM files across the project to change the parent version from 1.3.15.bugfix to 1.3.16. Additionally, the root POM file updates the project version and upgrades the JNA dependency from 5.5.0 to 5.7.0. A minor change in a test class adds a line to set the group ID for log storage options.

Changes

Files Change Summary
jraft-core/pom.xml, jraft-example/pom.xml, jraft-extension/{bdb-log-storage-impl, java-log-storage-impl, rpc-grpc-impl}/pom.xml, jraft-extension/pom.xml, jraft-rheakv/{pom.xml, rheakv-core/pom.xml, rheakv-pd/pom.xml}, jraft-test/pom.xml Updated parent project version from 1.3.15.bugfix to 1.3.16 in Maven POM files.
pom.xml Updated project version from 1.3.15.bugfix to 1.3.16 and upgraded JNA dependency version from 5.5.0 to 5.7.0.
jraft-extension/bdb-log-storage-impl/.../BaseLogStorageTest.java Added opts.setGroupId("test"); in the newLogStorageOptions method.

Possibly related PRs

Suggested labels

cla:no, size/M

Suggested reviewers

  • killme2008
  • fengjiachun

Poem

I’m hopping through the code with glee,
Updating versions for all to see.
From bugfix trails to numbers new,
A tiny change, but oh so true!
With a twitch of my nose and a nibble of cheer,
I celebrate these updates, dear developers near!
🐇💻 Happy coding, one and all!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9029048 and 5962989.

📒 Files selected for processing (12)
  • jraft-core/pom.xml (1 hunks)
  • jraft-example/pom.xml (1 hunks)
  • jraft-extension/bdb-log-storage-impl/pom.xml (1 hunks)
  • jraft-extension/bdb-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/impl/BaseLogStorageTest.java (1 hunks)
  • jraft-extension/java-log-storage-impl/pom.xml (1 hunks)
  • jraft-extension/pom.xml (1 hunks)
  • jraft-extension/rpc-grpc-impl/pom.xml (1 hunks)
  • jraft-rheakv/pom.xml (1 hunks)
  • jraft-rheakv/rheakv-core/pom.xml (1 hunks)
  • jraft-rheakv/rheakv-pd/pom.xml (1 hunks)
  • jraft-test/pom.xml (1 hunks)
  • pom.xml (2 hunks)
✅ Files skipped from review due to trivial changes (9)
  • jraft-core/pom.xml
  • jraft-rheakv/rheakv-pd/pom.xml
  • jraft-test/pom.xml
  • jraft-extension/bdb-log-storage-impl/pom.xml
  • jraft-rheakv/rheakv-core/pom.xml
  • jraft-rheakv/pom.xml
  • jraft-extension/rpc-grpc-impl/pom.xml
  • jraft-extension/pom.xml
  • jraft-extension/java-log-storage-impl/pom.xml
🔇 Additional comments (4)
jraft-extension/bdb-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/impl/BaseLogStorageTest.java (1)

72-72:

❓ Verification inconclusive

LGTM! Fix for NPE in testTruncatePrefix.

The change addresses the NPE by setting a non-null groupId for LogStorageOptions, which prevents null key access in the ConcurrentHashMap within ThreadPoolsFactory#runInThread.

Run the following script to verify the fix:


🏁 Script executed:

#!/bin/bash
# Description: Verify that testTruncatePrefix test passes with the fix.

# Test: Search for any remaining NPE occurrences in test logs.
rg -A 5 $'NullPointerException.*ThreadPoolsFactory#runInThread'

Length of output: 64


Action Required: Please manually confirm that testTruncatePrefix now runs cleanly.

The change in
jraft-extension/bdb-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/impl/BaseLogStorageTest.java (line 72) sets the groupId to "test" and should prevent the NPE in ThreadPoolsFactory#runInThread. A log search using

rg -A 5 'NullPointerException.*ThreadPoolsFactory#runInThread'

returned no output. However, please run the test suite manually to fully verify that no NPE occurs during testTruncatePrefix.

jraft-example/pom.xml (1)

8-8: LGTM! Version update is consistent.

The parent version update to 1.3.16 aligns with the root POM version update.

pom.xml (2)

7-7: LGTM! Version update follows semantic versioning.

The project version update from 1.3.15.bugfix to 1.3.16 is consistent across all modules.


66-66:

✅ Verification successful

LGTM! JNA upgrade for Apple Silicon support.

The JNA version upgrade from 5.5.0 to 5.7.0 adds support for Apple Silicon processors.

Let's verify that JNA 5.7.0 supports Apple Silicon:


🌐 Web query:

Does JNA 5.7.0 support Apple Silicon (M1/M2) processors?

💡 Result:

Yes, JNA 5.7.0 supports Apple Silicon (M1/M2) processors when using native ARM64 builds[7][4]. Key points:

Native ARM64 Support

  • Requires Java running natively on ARM64 architecture (e.g., using Zulu/Azul JDK or other ARM-compatible JDK)[4][7]
  • Fixes critical macOS compatibility issues present in earlier JNA versions[1][5]
  • Enables proper hardware detection through libraries like OSHI[7]

Key Requirements

  1. Use JNA ≥5.7.0[7]
  2. Ensure no dependencies override with older JNA versions[4]
  3. Verify Java process is running in ARM64 mode (not x86 emulation via Rosetta)[7]

Performance Considerations

  • Native ARM64 execution shows better performance than Rosetta x86 emulation[4]
  • Some Java tools may still require Rosetta if they lack ARM64 builds[3]

Developers report successful usage with:

  • Testcontainers[4]
  • OSHI hardware monitoring[7]
  • Neo4j databases[10]

The upgrade path typically involves updating dependencies and verifying architecture compatibility through tools like System.getProperty("os.arch") returning aarch64[4][7].

Citations:


LGTM – Verified JNA 5.7.0’s Apple Silicon support

The upgrade to JNA 5.7.0 is confirmed to support Apple Silicon (M1/M2) processors when running on native ARM64 builds. No further modifications are needed.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants