Skip to content

TRUNK-000: Add null safety check in MySQLBooleanType#6005

Open
Kanishka680 wants to merge 1 commit intoopenmrs:masterfrom
Kanishka680:master
Open

TRUNK-000: Add null safety check in MySQLBooleanType#6005
Kanishka680 wants to merge 1 commit intoopenmrs:masterfrom
Kanishka680:master

Conversation

@Kanishka680
Copy link
Copy Markdown

Added a null guard in toDatabaseDataType to prevent potential NullPointerExceptions when the database object is null. This ensures safer delegation to the super class.

Description of what I changed

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

Added a null guard in toDatabaseDataType to prevent potential NullPointerExceptions when the database object is null. This ensures safer delegation to the super class.
@sonarqubecloud
Copy link
Copy Markdown

@sudhanshu-raj
Copy link
Copy Markdown
Contributor

This look small but slightly useful one to be defensive against NPE but it would be better where you could add before and after scenario via the test cases which will prove and demonstrate this change . And please raise the ticket for traceability before the PR.


@Override
public DatabaseDataType toDatabaseDataType(Database database) {
if (database == null) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing null safety guards in the database layer is a fundamental best practice for preventing unpredictable NullPointerExceptions. The logic here is concise and matches the core module's patterns.

Copy link
Copy Markdown

@ashuverma25 ashuverma25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, these null safety guards are a great addition to the persistence layer. The implementation is clean and follows our standard architectural patterns.

@stefanachiorean
Copy link
Copy Markdown

The null safety check looks appropriate here. One suggestion: it might be worth adding a brief inline comment explaining why the null check is necessary in this specific context, to make the intent clearer for future contributors reading the code.

Copy link
Copy Markdown

@fierce-adventurer fierce-adventurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You PR format is invalid you need to create a ticket on jira before dropping a PR secondly you have not checked out any test cases third you should tell in your pr what your issue was and what the code does , also for every method you write you need to write junit tests to check if anything is broken due to your code.
RTFM before dropping the PR.

Copy link
Copy Markdown

@Nis200111 Nis200111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null safety check added to toDatabaseDataType in MySQLBooleanType is a great practice. It prevents potential NullPointerExceptions during database operations. Code looks solid.

Copy link
Copy Markdown

@Nis200111 Nis200111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good null safety check in MySQLBooleanType. It prevents potential NullPointerExceptions. LGTM!

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.

6 participants