Skip to content

fix(user): prevent permanent import lockout on unchecked exceptions#3779

Open
Priyasharma620064 wants to merge 1 commit intoeclipse-sw360:mainfrom
Priyasharma620064:fix/user-import-lockout
Open

fix(user): prevent permanent import lockout on unchecked exceptions#3779
Priyasharma620064 wants to merge 1 commit intoeclipse-sw360:mainfrom
Priyasharma620064:fix/user-import-lockout

Conversation

@Priyasharma620064
Copy link
Contributor

Summary

Fixes the IMPORT_DEPARTMENT_STATUS flag in UserDatabaseHandler.importFileToDB() which can get permanently stuck at true after an unchecked exception, disabling department import until server restart.
-This PR fixes issue #3778 by moving the flag reset to a finally block and replacing the plain static boolean with AtomicBoolean.compareAndSet() for thread-safe guarding.
-No new dependencies added. AtomicBoolean is part of java.util.concurrent.atomic (standard JDK).

Issue: #3778

Suggest Reviewer

@GMishx

How To Test?

  1. Verify the flag resets correctly on success — trigger a department import with valid files and confirm it completes and can be re-triggered
  2. Verify the flag resets on failure — trigger an import with a malformed Excel file (blank second column) and confirm the next import attempt works instead of returning PROCESSING forever
  3. Verify concurrent guard — trigger a manual import while a scheduled import is running and confirm the second call returns PROCESSING (not both running simultaneously)

@GMishx GMishx added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Mar 2, 2026
Comment on lines +218 to 220
} finally {
IMPORT_DEPARTMENT_STATUS.set(false);
}
Copy link
Member

Choose a reason for hiding this comment

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

finally block will always run irrespective if there was an exception or not. This will result in IMPORT_DEPARTMENT_STATUS to always be false.

The IMPORT_DEPARTMENT_STATUS flag in UserDatabaseHandler.importFileToDB()
is only reset inside try and catch(IOException). Any unchecked exception
leaves the flag stuck at true, permanently disabling department import
until server restart.
- Move flag reset to finally block for guaranteed reset
- Replace static boolean with AtomicBoolean.compareAndSet() for thread-safe
  guarding between Timer scheduler and Thrift request threads
closes eclipse-sw360#3778

Signed-off-by: Priya Sharma <priyasharma1001a@gmail.com>
@Priyasharma620064 Priyasharma620064 force-pushed the fix/user-import-lockout branch from 2b7c5ab to 9a7ffa7 Compare March 2, 2026 09:29
@Priyasharma620064
Copy link
Contributor Author

Thanks @GMishx! Updated — moved log writes inside finally so the flag resets only after all work is done. Also added catch (Exception e) to handle unchecked exceptions gracefully. Please re-review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs code review needs general test This is general testing, meaning that there is no org specific issue to check for

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants