Skip to content

Commit

Permalink
Fix in scope handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolvlsantos committed Dec 6, 2023
1 parent 2dc43f7 commit 854a4b0
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.thiagolvlsantos.git.transactions.scope;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

Expand All @@ -13,8 +13,8 @@
@Slf4j
public class AspectScope implements Scope {

private List<Map<String, Object>> scope = new LinkedList<>();
private List<Map<String, Runnable>> destruction = new LinkedList<>();
private List<Map<String, Object>> scope = new ArrayList<>();
private List<Map<String, Runnable>> destruction = new ArrayList<>();

public void openAspect() {
scope.add(new HashMap<>());
Expand Down Expand Up @@ -105,11 +105,21 @@ public String getConversationId() {
}

public void closeAspect() {
int scopePos = scope.size() - 1;
if (!scope.isEmpty()) {
scope.remove(scope.size() - 1);
if (scopePos >= 0) {
scope.remove(scopePos);
} else {
log.info("Invalid scope:{}", scopePos);
}
}
int destructionPos = destruction.size() - 1;
if (!destruction.isEmpty()) {
destruction.remove(destruction.size() - 1);
if (destructionPos >= 0) {
destruction.remove(destructionPos);
} else {
log.info("Invalid destruction:{}", destructionPos);
}
}
log.debug("Scope closed.");
}
Expand Down

0 comments on commit 854a4b0

Please sign in to comment.