forked from apache/incubator-seata
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: filter repeated lock (apache#1839)
- Loading branch information
1 parent
9dab05d
commit 5730057
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,5 +109,9 @@ enum TransactionExceptionCodeProto { | |
*/ | ||
FailedWriteSession = 16; | ||
|
||
/** | ||
* FailedStore | ||
*/ | ||
FailedStore = 17; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
common/src/main/java/io/seata/common/util/LambdaUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.seata.common.util; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* The type Lambda util. | ||
* | ||
* @author zjinlei | ||
* @date 2019 /10/29 | ||
*/ | ||
public class LambdaUtils { | ||
|
||
public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) { | ||
Map<Object, Boolean> seen = new ConcurrentHashMap<>(); | ||
return object -> seen.putIfAbsent(keyExtractor.apply(object), Boolean.TRUE) == null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters