Skip to content

Commit

Permalink
Pull out getters into the InMemoryExceptionLogger
Browse files Browse the repository at this point in the history
:
  • Loading branch information
osamahan999 committed Dec 7, 2023
1 parent e78a5ce commit 0992323
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.datatransferproject.spi.transfer.idempotentexecutor;

import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import org.datatransferproject.types.transfer.errors.ErrorDetail;
Expand All @@ -18,6 +20,14 @@ private void logError(String idempotentId, ErrorDetail errorDetail) {
this.recentErrors.put(idempotentId, errorDetail);
}

public Collection<ErrorDetail> getErrors() {
return ImmutableList.copyOf(errors.values());
}

public Collection<ErrorDetail> getRecentErrors() {
return ImmutableList.copyOf(recentErrors.values());
}

public ErrorDetail addError(
String idempotentId,
String itemName,
Expand All @@ -30,7 +40,6 @@ public ErrorDetail addError(
if (canSkip) {
errorDetailBuilder.setCanSkip(true);
}

ErrorDetail errorDetail = errorDetailBuilder.build();

logError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,11 @@ public boolean isKeyCached(String idempotentId) {
return knownValues.containsKey(idempotentId);
}

@Override
public Collection<ErrorDetail> getErrors() {
return ImmutableList.copyOf(errors.values());
}

@Override
public void setJobId(UUID jobId) {
this.jobId = jobId;
}

@Override
public Collection<ErrorDetail> getRecentErrors() {
return ImmutableList.copyOf(recentErrors.values());
}

@Override
public void resetRecentErrors() {
recentErrors.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,11 @@ public boolean isKeyCached(String idempotentId) {
return knownValues.containsKey(idempotentId);
}

@Override
public Collection<ErrorDetail> getErrors() {
return ImmutableList.copyOf(errors.values());
}

@Override
public void setJobId(UUID jobId) {
this.jobId = jobId;
}

@Override
public Collection<ErrorDetail> getRecentErrors() {
return ImmutableList.copyOf(recentErrors.values());
}

@Override
public void resetRecentErrors() {
recentErrors.clear();
Expand Down

0 comments on commit 0992323

Please sign in to comment.