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

EPMRPP-82591 || Logs with attachments null pointer #949

Merged
merged 5 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public LocalDataStore(BlobStore blobStore, FeatureFlagHandler featureFlagHandler

@Override
public String save(String filePath, InputStream inputStream) {
if (filePath == null) {
return "";
}
StoredFile storedFile = getStoredFile(filePath);
try {
if (!blobStore.containerExists(storedFile.getBucket())) {
Expand All @@ -69,6 +72,9 @@ public String save(String filePath, InputStream inputStream) {

@Override
public InputStream load(String filePath) {
if (filePath == null) {
throw new ReportPortalException(ErrorType.UNABLE_TO_LOAD_BINARY_DATA, "Unable to find file");
}
StoredFile storedFile = getStoredFile(filePath);
Blob fileBlob = blobStore.getBlob(storedFile.getBucket(), storedFile.getFilePath());
if (fileBlob != null) {
Expand All @@ -83,6 +89,9 @@ public InputStream load(String filePath) {

@Override
public boolean exists(String filePath) {
if (filePath == null) {
return false;
}
StoredFile storedFile = getStoredFile(filePath);
if (blobStore.containerExists(storedFile.getBucket())) {
return blobStore.blobExists(storedFile.getBucket(), storedFile.getFilePath());
Expand All @@ -94,6 +103,9 @@ public boolean exists(String filePath) {

@Override
public void delete(String filePath) {
if (filePath == null) {
return;
}
StoredFile storedFile = getStoredFile(filePath);
try {
blobStore.removeBlob(storedFile.getBucket(), storedFile.getFilePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public S3DataStore(BlobStore blobStore, String bucketPrefix, String bucketPostfi

@Override
public String save(String filePath, InputStream inputStream) {
if (filePath == null) {
return "";
}
StoredFile storedFile = getStoredFile(filePath);
try {
if (!blobStore.containerExists(storedFile.getBucket())) {
Expand All @@ -91,7 +94,8 @@ public String save(String filePath, InputStream inputStream) {
}

Blob objectBlob = blobStore.blobBuilder(storedFile.getFilePath()).payload(inputStream)
.contentDisposition(storedFile.getFilePath()).contentLength(inputStream.available()).build();
.contentDisposition(storedFile.getFilePath()).contentLength(inputStream.available())
.build();
blobStore.putBlob(storedFile.getBucket(), objectBlob);
return Paths.get(filePath).toString();
} catch (IOException e) {
Expand All @@ -102,6 +106,10 @@ public String save(String filePath, InputStream inputStream) {

@Override
public InputStream load(String filePath) {
if (filePath == null) {
LOGGER.error("Unable to find file");
throw new ReportPortalException(ErrorType.UNABLE_TO_LOAD_BINARY_DATA, "Unable to find file");
}
StoredFile storedFile = getStoredFile(filePath);
Blob fileBlob = blobStore.getBlob(storedFile.getBucket(), storedFile.getFilePath());
if (fileBlob != null) {
Expand All @@ -117,12 +125,18 @@ public InputStream load(String filePath) {

@Override
public boolean exists(String filePath) {
if (filePath == null) {
return false;
}
StoredFile storedFile = getStoredFile(filePath);
return blobStore.blobExists(storedFile.getBucket(), storedFile.getFilePath());
}

@Override
public void delete(String filePath) {
if (filePath == null) {
return;
}
StoredFile storedFile = getStoredFile(filePath);
try {
blobStore.removeBlob(storedFile.getBucket(), storedFile.getFilePath());
Expand Down
Loading