Skip to content

Commit 64c745f

Browse files
committed
Extract singletons for constant retry decisions.
1 parent 8a2a0af commit 64c745f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

driver-core/src/main/java/com/datastax/driver/core/policies/RetryPolicy.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public interface RetryPolicy {
4141
* </ul>
4242
*/
4343
class RetryDecision {
44+
45+
private static final RetryDecision RETHROW_DECISION = new RetryDecision(Type.RETHROW, null, true);
46+
private static final RetryDecision IGNORE_DECISION = new RetryDecision(Type.IGNORE, null, true);
47+
4448
/**
4549
* The types of retry decisions.
4650
*/
@@ -99,7 +103,7 @@ public boolean isRetryCurrent() {
99103
* @return a {@link RetryDecision.Type#RETHROW} retry decision.
100104
*/
101105
public static RetryDecision rethrow() {
102-
return new RetryDecision(Type.RETHROW, null, true);
106+
return RETHROW_DECISION;
103107
}
104108

105109
/**
@@ -128,7 +132,7 @@ public static RetryDecision retry(ConsistencyLevel consistency) {
128132
* @return an {@link RetryDecision.Type#IGNORE} retry decision.
129133
*/
130134
public static RetryDecision ignore() {
131-
return new RetryDecision(Type.IGNORE, null, true);
135+
return IGNORE_DECISION;
132136
}
133137

134138
/**

0 commit comments

Comments
 (0)