/*
 * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed 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 com.hazelcast.jet2.impl;

public abstract class AsyncOperation extends EngineOperation {

    private long callId = -1;

    public AsyncOperation() {
    }

    public AsyncOperation(String engineName) {
        super(engineName);
    }

    @Override
    public boolean returnsResponse() {
        return false;
    }

    @Override
    public Object getResponse() {
        throw new UnsupportedOperationException();
    }

    @Override
    protected void onSetCallId() {
        if (callId == -1) {
            callId = getCallId();
        }
    }

    @Override
    public void beforeRun() throws Exception {
        this.<JetService>getService().registerOperation(getCallerAddress(), getCallId());
    }

    @Override
    public final void run() throws Exception {
        try {
            doRun();
        } catch (Exception e) {
            logError(e);
            doSendResponse(e);
        }
    }

    protected abstract void doRun() throws Exception;

    protected final void doSendResponse(Object value) {
        try {
            sendResponse(value);
        } finally {
            this.<JetService>getService().deregisterOperation(getCallerAddress(), callId);
        }
    }


}

@@ -728,43 +728,15 @@
   pr
-ivate long callId = -1;%0A%0A    public
+otected
  Asy
@@ -1031,136 +1031,8 @@
  %7D%0A%0A
-    @Override%0A    protected void onSetCallId() %7B%0A        if (callId == -1) %7B%0A            callId = getCallId();%0A        %7D%0A    %7D%0A%0A
     
@@ -1650,14 +1650,19 @@
 (), 
-c
+getC
 allId
+()
 );%0A 
@@ -1676,12 +1676,10 @@
 %7D%0A    %7D%0A
-%0A%0A
 %7D%0A

Remove cached call ID from AsyncOperation