gemmellr commented on a change in pull request #3983:
URL: https://github.com/apache/activemq-artemis/pull/3983#discussion_r829177891



##########
File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
##########
@@ -189,13 +198,45 @@ public PagingStoreImpl(final SimpleString address,
       this.usingGlobalMaxSize = pagingManager.isUsingGlobalSize();
    }
 
+   private static SizeAwareMetric getGlobalMetric(PagingManager manager) {
+      if (manager instanceof PagingManagerImpl) {
+         return ((PagingManagerImpl) manager).getSizeAwareMetric();
+      } else {
+         // for unit / mock tests
+         SizeAwareMetric metric = new SizeAwareMetric(-1, -1, -1, -1, -1, 1, 
1, 0, 0);
+         metric.addOnSizeCallback(manager::addSize, false);
+         metric.addOnSizeCallback((l) -> manager.addSize(l, true), true);
+         return metric;
+      }
+   }

Review comment:
       Having internal detail is fine. The main point was really the other bit 
though, its generally a bad idea for non-test code to be just suddenly 
returning objects only intended for [certain] tests. At some point something 
will unexpectedly get one of those instead of the real thing, when theres no 
reason they really should know the behaviour is there. Better for tests that 
need to to know and apply the test logic they need.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to