Skip to content

initNews NPE fix #405

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

Merged
merged 2 commits into from
Jun 10, 2025
Merged

initNews NPE fix #405

merged 2 commits into from
Jun 10, 2025

Conversation

Naenyn
Copy link
Contributor

@Naenyn Naenyn commented Jun 10, 2025

Adds some null checking and modifies the handling of newly created newsSets.

Adds some null checking and modifies the handling of newly created
newsSets.
@Naenyn Naenyn requested review from bjagg and Copilot June 10, 2025 19:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes potential null pointer exceptions by adding null checks and refining the handling of news set creation and retrieval. Key changes include:

  • Added null checks for PortletRequest and userId in SharedNewsSetServiceImpl.
  • Enhanced error handling when persisting and retrieving NewsSet objects.
  • Added additional null checks for the roles and NewsSet parameters in HibernateNewsStore.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/jasig/portlet/newsreader/service/SharedNewsSetServiceImpl.java Added null checks and updated error handling during NewsSet creation and retrieval.
src/main/java/org/jasig/portlet/newsreader/mvc/portlet/reader/AjaxNewsController.java Added null check for NewsSet and updated flow to return a friendly error message.
src/main/java/org/jasig/portlet/newsreader/dao/HibernateNewsStore.java Introduced null checks for NewsSet and roles in initNews and storeNewsSet methods.
Comments suppressed due to low confidence (1)

src/main/java/org/jasig/portlet/newsreader/service/SharedNewsSetServiceImpl.java:122

  • [nitpick] Consider revising 're-initalising' to 'reinitializing' for improved readability and consistency.
logger.debug("re-initalising loaded newsSet " + set.getName());

}
}
} catch (Exception e) {
logger.error("Error creating NewsSet for userId={}, fname={}: {}", userId, fname, e.getMessage());
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

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

Consider logging the full exception (e.g., by passing 'e' as a parameter) to aid debugging rather than just logging the exception message.

Suggested change
logger.error("Error creating NewsSet for userId={}, fname={}: {}", userId, fname, e.getMessage());
logger.error("Error creating NewsSet for userId={}, fname={}", userId, fname, e);

Copilot uses AI. Check for mistakes.

Copy link
Member

@bjagg bjagg left a comment

Choose a reason for hiding this comment

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

🏅

@bjagg bjagg merged commit f04d601 into uPortal-Project:master Jun 10, 2025
8 checks passed
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