Elffuss BraidHub

kikocis/java-driver public

Extract constants for invariable retry decisions

These methods always return the same result. Extract constants to avoid
building a new object each time (even though the JVM probably optimized
it eventually).
Changeset8597902e03c229638fe372668a208055cb265d1aea960f66eef918c5a6dabe70
Authorolim7t <omichallat+github@gmail.com> · 2016-06-20 17:03 -07:00
Committerolim7t <omichallat+github@gmail.com> · 2016-07-18 13:35 -07:00
Parents4c7d7faed12e

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/policies/RetryPolicy.java +6 −2
@@ -41,6 +41,10 @@
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 @@
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 @@
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 /**