You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/04/17 19:43:09 UTC

[GitHub] [commons-lang] oheger commented on a change in pull request #275: [LANG-1339]: deprecate circuit breakers and replace java.beans.PropertyListener by a Consumer

oheger commented on a change in pull request #275: [LANG-1339]: deprecate circuit breakers and replace java.beans.PropertyListener by a Consumer<State>
URL: https://github.com/apache/commons-lang/pull/275#discussion_r410433546
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/concurrent/BaseCircuitBreaker.java
 ##########
 @@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.concurrent;
+
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Consumer;
+
+
+/**
+ * Base class for circuit breakers.
+ *
+ * @param <T> the type of the value monitored by this circuit breaker
+ * @since 3.11
+ */
+public abstract class BaseCircuitBreaker<T> implements CircuitBreaker<T> {
+
+    /** The current state of this circuit breaker. */
+    protected final AtomicReference<State> state = new AtomicReference<>(State.CLOSED);
+
+    /**
+     * Consumer called every time the circuit breaker state changes if not {@code null}.
+     */
+    private final Consumer<State> consumer;
+
+    /**
+     * Creates an {@code AbstractCircuitBreaker}. It also creates an internal {@code PropertyChangeSupport}.
 
 Review comment:
   There is still an outdated reference to PropertyChangeSupport in the commend.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services