clebertsuconic commented on a change in pull request #2976: ARTEMIS-2325 + a test fix URL: https://github.com/apache/activemq-artemis/pull/2976#discussion_r377930173
########## File path: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/SendAcknowledgementHandlerWrapper.java ########## @@ -0,0 +1,62 @@ +/** + * 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.core.client.impl; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; + +public class SendAcknowledgementHandlerWrapper implements SendAcknowledgementHandler { + + private SendAcknowledgementHandler wrapped; + + /** + * It's possible that a SendAcknowledgementHandler might be called twice due to subsequent + * packet confirmations on the same connection. Using this boolean avoids that possibility. + * A new SendAcknowledgementHandlerWrapper is created for each message sent so once it's + * called once it will never be called again. + */ + private AtomicBoolean active = new AtomicBoolean(true); Review comment: fair enough.. can you at least use a regular volatile boolean here? the sendAck is called from a single thread. I think it's safe to use a regular boolean here. if you really want Atomics used, can you use a AtomicIntegerFieldUpdater instead? have a counter and only call this if the counter == 0. AtomicBoolean will be heavier then a regular field. That's the only change I will ask, on top of the favour I asked you. (removing the XXX) ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
