Skip to content

Improper Exception Handling in License Upload Stream Cleanup #3895

@melbiialy

Description

@melbiialy

Bug: License Upload Loses Original Error When Stream Cleanup Fails

Description

When uploading a license file fails, the error message can be replaced by a stream cleanup error, hiding the real problem.

What's wrong:

  • If license import fails AND stream cleanup also fails, you only see the cleanup error
  • The actual reason for the import failure is lost
  • No validation check if file is null or empty

How to Reproduce

  1. Upload an invalid license archive to /api/licenses/upload
  2. If the import fails and a stream also fails to close
  3. The logs only show "Failed to close stream" instead of the actual import error

Location

File: rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/license/Sw360LicenseService.java
Method: uploadLicense() (line ~273)

The Problem

} finally {
    // ... cleanup code ...
    if (closeFailure != null) {
        throw closeFailure;  // This hides the original exception!
    }
}

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