@@ -132,12 +132,12 @@ public class Scope extends BasicScope implements IScope, IScopeStatistics, Scope
132132 /**
133133 * Child scopes
134134 */
135- private final transient ConcurrentScopeSet children ;
135+ private final transient ConcurrentScopeSet children = new ConcurrentScopeSet () ;
136136
137137 /**
138138 * Connected clients map
139139 */
140- private final transient CopyOnWriteArraySet <IClient > clients ;
140+ private final transient CopyOnWriteArraySet <IClient > clients = new CopyOnWriteArraySet <>() ;
141141
142142 /**
143143 * Statistics about connections to the scope.
@@ -176,8 +176,6 @@ public class Scope extends BasicScope implements IScope, IScopeStatistics, Scope
176176 @ ConstructorProperties (value = { "" })
177177 public Scope () {
178178 super (null , ScopeType .UNDEFINED , null , false );
179- children = new ConcurrentScopeSet ();
180- clients = new CopyOnWriteArraySet <IClient >();
181179 makeInternalWorker ();
182180 }
183181
@@ -191,26 +189,27 @@ public Scope() {
191189 */
192190 public Scope (IScope parent , ScopeType type , String name , boolean persistent ) {
193191 super (parent , type , name , persistent );
194- children = new ConcurrentScopeSet ();
195- clients = new CopyOnWriteArraySet <IClient >();
196192 makeInternalWorker ();
197193 }
198194
199195 // XXX: temporary internal worker to run code periodically
200196 private void makeInternalWorker () {
201- if (doRun .compareAndSet (false , true )) {
202- Thread .ofVirtual ().start (() -> {
203- while (doRun .get ()) {
204- try {
205- Thread .sleep (10000 );
206- runInspectionCode ();
207- } catch (InterruptedException e ) {
208- break ;
209- } catch (Exception e ) {
210- log .error ("Exception in internal worker" , e );
197+ if (log .isTraceEnabled ()) {
198+ log .trace ("Making internal worker for scope: {}" , this );
199+ if (doRun .compareAndSet (false , true )) {
200+ Thread .ofVirtual ().start (() -> {
201+ while (doRun .get ()) {
202+ try {
203+ Thread .sleep (10000 );
204+ runInspectionCode ();
205+ } catch (InterruptedException e ) {
206+ break ;
207+ } catch (Exception e ) {
208+ log .error ("Exception in internal worker" , e );
209+ }
211210 }
212- }
213- });
211+ });
212+ }
214213 }
215214 }
216215
@@ -267,15 +266,7 @@ protected void runInspectionCode() {
267266 log .error ("Stream: {} actual subscriber count: {}" , pubStreamName , subscriberCount );
268267 }
269268 }
270- /*
271- LoggingEventBuilder lb = log.atError();
272- lb.addArgument(subSubscriberCount);
273- lb.addArgument(pubSubscriberCount);
274- lb.setMessage("HEY YOU GUYS. subs count: {} pub count: {}");
275- lb.log();
276- */
277269 }
278-
279270 }
280271 } else {
281272 log .debug ("Connection is not stream capable: {}" , conn );
0 commit comments