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

TFP-5818: Sjekker at kobling er aktiv da man skal ta skrive lås. Sonar. #2646

Merged
merged 2 commits into from
Mar 13, 2025

Conversation

mrsladek
Copy link
Collaborator

Testet ok lokalt.

@mrsladek mrsladek requested a review from a team as a code owner March 13, 2025 07:59
@github-actions github-actions bot added the web label Mar 13, 2025
@mrsladek mrsladek requested review from pekern, jolarsen and Copilot March 13, 2025 08:00

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request (TFP-5818) ensures that a kobling (connection) is active when a write lock is taken, in response to Sonar findings. The changes include:

  • Adding a conditional clause to the JPQL query in KoblingRepository to only include active koblinger when a write lock is requested.
  • Updating the exception signatures for the main methods in both JettyDevServer and JettyServer.
  • Removing try-catch blocks in JettyServer.start() to allow exceptions to propagate for improved error visibility.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
domenetjenester/kobling/src/main/java/no/nav/foreldrepenger/abakus/kobling/repository/KoblingRepository.java Adds a conditional JPQL filter to check if the kobling is active when write lock is needed.
web/src/test/java/no/nav/foreldrepenger/abakus/jetty/JettyDevServer.java Removes an unused import and updates the main method’s exception signature.
web/src/main/java/no/nav/foreldrepenger/abakus/jetty/JettyServer.java Changes main method and bootStrap exception declarations and removes the try-catch in the start method to propagate exceptions.
Comments suppressed due to low confidence (1)

domenetjenester/kobling/src/main/java/no/nav/foreldrepenger/abakus/kobling/repository/KoblingRepository.java:46

  • [nitpick] Consider renaming the variable 'sql' to 'jpql' to more accurately reflect that the query is a JPQL query, not raw SQL.
var sql = "FROM Kobling k WHERE koblingReferanse = :referanse";
@mrsladek mrsladek requested a review from Copilot March 13, 2025 09:12
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 implements a check to ensure that a kobling (connection) is active before taking a write lock, and makes adjustments to exception handling in the Jetty server startup methods. Key changes include:

  • In KoblingRepository.java, the JPQL query is updated to conditionally add an "active" check when a write lock is requested.
  • In JettyDevServer.java and JettyServer.java, the main methods and bootStrap method signatures are updated to throw Exception instead of NamingException, and the start() method now propagates exceptions instead of handling them internally.

Reviewed Changes

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

File Description
domenetjenester/kobling/src/main/java/no/nav/foreldrepenger/abakus/kobling/repository/KoblingRepository.java Added conditional JPQL modification to check if kobling is active before taking a write lock.
web/src/test/java/no/nav/foreldrepenger/abakus/jetty/JettyDevServer.java Removed unused import and updated main method exception clause.
web/src/main/java/no/nav/foreldrepenger/abakus/jetty/JettyServer.java Updated main and bootStrap methods to throw Exception and removed exception swallowing in start().
Comments suppressed due to low confidence (1)

domenetjenester/kobling/src/main/java/no/nav/foreldrepenger/abakus/kobling/repository/KoblingRepository.java:48

  • [nitpick] Ensure that the concatenated JPQL query remains valid as additional conditions may be added in the future. Consider using a StringBuilder or another query-building approach for clarity and maintainability.
jpql += " and k.aktiv = true";

@mrsladek mrsladek merged commit 42f3d8a into master Mar 13, 2025
12 checks passed
@mrsladek mrsladek deleted the feat/TFP-5818_sjekk_aktiv_flagg_kobling branch March 13, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants