Skip to content

Department import permanently disabled after unchecked exception in UserDatabaseHandler #3778

@Priyasharma620064

Description

@Priyasharma620064

Description

The IMPORT_DEPARTMENT_STATUS flag in UserDatabaseHandler.importFileToDB() can get stuck at true.
When this happens, the department import feature stops working and only starts working again after a server restart.
Right now, the flag is reset only when the import finishes successfully or when an IOException occurs. If any other exception happens (for example, a NullPointerException caused by a malformed Excel row like row.getCell(1).getStringCellValue() returning null), the flag is never reset.

As a result:
-The flag stays true
-Every future import request immediately returns RequestStatus.PROCESSING
-The feature remains blocked until the server is restarted

In addition, the flag is a simple static boolean and is accessed by two different threads:
-The scheduler thread (importDepartmentSchedule())
-The REST-triggered import thread (importDepartmentManually())

Since there is no synchronization, two threads could enter the import at the same time, causing a race condition.

How to reproduce

-Configure a department import folder path via POST /departments/writePathFolder
-Place a malformed Excel file in the folder (e.g., a row with a blank second column)
-Trigger import via POST /departments/manuallyactive
-The import throws NullPointerException at row.getCell(1).getStringCellValue()
-Try triggering another import via POST /departments/manuallyactive

Result: Returns RequestStatus.PROCESSING indefinitely — feature is permanently locked
Expected: Import should recover and allow retries.

SW360 logs

When the bug triggers, the following pattern appears:
-First import: NullPointerException stack trace in server logs
-All subsequent imports: No log output (method returns early before any logging)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions