gemmellr commented on code in PR #4418:
URL: https://github.com/apache/activemq-artemis/pull/4418#discussion_r1154381133
##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java:
##########
@@ -16,12 +16,57 @@
*/
package org.apache.activemq.artemis.api.core;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-// import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet; --
#ifdef DEBUG
+import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
+import org.apache.activemq.artemis.utils.ObjectCleaner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RefCountMessage {
+ private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Review Comment:
Looks unused.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java:
##########
@@ -27,6 +27,8 @@
public interface LargeServerMessage extends ReplicatedLargeMessage {
+ boolean DEBUG =
Boolean.parseBoolean(System.getProperty("ARTEMIS_LARGE_MESSAGE_DEBUG",
"false"));
Review Comment:
Perhaps ARTEMIS_LARGE_SERVER_MESSAGE_DEBUG to make it more specific to its
usage?
##########
tests/leak-tests/src/test/java/org/apache/activemq/artemis/tests/leak/RefCountMessageLeakTest.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.activemq.artemis.tests.leak;
+
+import java.lang.invoke.MethodHandles;
+
+import io.github.checkleak.core.CheckLeak;
+import org.apache.activemq.artemis.api.core.RefCountMessage;
+import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RefCountMessageLeakTest extends ActiveMQTestBase {
+
+ private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Review Comment:
Looks unused.
##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java:
##########
@@ -344,4 +344,7 @@ public interface ActiveMQClientLogger {
@LogMessage(id = 214033, value = "Cannot resolve host ", level =
LogMessage.Level.ERROR)
void unableToResolveHost(UnknownHostException e);
+
+ @LogMessage(id = 214034, value = "{} is being garbage collected without
removing its resources.:\nlocations:\n{}", level = LogMessage.Level.INFO)
+ void debugMessageNotReleased(String clazz, String debugString);
Review Comment:
This debug stuff only seems to be used on the server, so it seems odd to
have the log method in ActiveMQClientLogger?
##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java:
##########
@@ -58,55 +108,35 @@ public int getDurableCount() {
public RefCountMessage getParentRef() {
return parentRef;
}
- // I am usually against keeping commented out code
- // However this is very useful for me to debug referencing counting.
- // Uncomment out anything between #ifdef DEBUG and #endif
- // #ifdef DEBUG -- comment out anything before endif if you want to debug
REFERENCE COUNTS
- //final ConcurrentHashSet<Exception> upSet = new ConcurrentHashSet<>();
- // #endif
+ protected void onUp() {
+ if (debugStatus != null) {
+ debugStatus.up(debugString());
+ }
+ }
- private void onUp() {
- // #ifdef DEBUG -- comment out anything before endif if you want to
debug REFERENCE COUNTS
- // upSet.add(new Exception("upEvent(" + debugString() + ")"));
- // #endif
+ protected void onFired() {
Review Comment:
Perhaps onDelete[d]? onRelease?
Calling it onFired() seems weird since its so often called when the
'releaseComplete()' being gated by the 'fired' variable apparently _has not_
been fired.
##########
tests/soak-tests/pom.xml:
##########
@@ -286,7 +286,7 @@
<configuration>${basedir}/target/classes/servers/lmbroker1</configuration>
<args>
<arg>--java-options</arg>
- <arg>-Djava.rmi.server.hostname=localhost</arg>
+ <arg>"-Djava.rmi.server.hostname=localhost</arg>
Review Comment:
This change seems odd
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ObjectCleaner.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.activemq.artemis.utils;
+
+public class ObjectCleaner {
+
+ public static void register(Object obj, Runnable callback) {
+ io.netty.util.internal.ObjectCleaner.register(obj, callback);
Review Comment:
Why the switch to an explicitly-internal and subject-to-change cleaner from
Netty, vs the java.lang.ref.Cleaner you used before?
--
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]