Skip to content

Fixing inconsistency between status code sent by storage service and that returned by file service

Aman Verma requested to merge users/amaverma/fixStatusCodeFromStorage into master

Description

It has been observed that at times Storage service, while storing metadata, sends one response code, let's say 401, while because of the same error, file service returns a different error code.

Reason

This happens because we have custom handling for StorageExceptions. At each place, the handling is different. We catch this exception, do some logging and prepare another Exception using details out the original exception.

Fix

Removing the custom handling of exceptions thrown by storage service. Each class would simply log an appropriate message and throw the original exception as is without tampering it. There's a RestExceptionHandler class already present https://community.opengroup.org/osdu/platform/system/file/-/blob/master/file-core/src/main/java/org/opengroup/osdu/file/exception/handler/RestExceptionHandler.java hence it'll handle all the StorageExceptions similarly. There are UTs to ensure that this RestExceptionHandler class retains the original error code/ error message, as sent by storage service.

Changes in this MR

  1. Removed custom handling of StorageException. Now each class would simply log and throw.
  2. Updated the method signature of services/ API classes to throw StorageException to make this behaviour consistent across all the concerned APIs. Previously, some APIs were throwing StorageException while others were catching it and wrapping it up in AppExceptions
  3. Updated UTs

What testing has been done

  1. UTs- GREEN
  2. ITs for Azure- GREEN

cc: @polavishnu @krveduru @pbehede

Edited by Aman Verma

Merge request reports