/*
 * Copyright (c) 2013 Spotify AB
 */

package com.spotify.apollo.request;

import com.spotify.apollo.Response;

import okio.ByteString;

class TrackedOngoingRequestImpl
    extends ForwardingOngoingRequest
    implements TrackedOngoingRequest {

  private final RequestTracker requestTracker;

  TrackedOngoingRequestImpl(
      OngoingRequest ongoingRequest,
      RequestTracker requestTracker) {
    super(ongoingRequest);
    this.requestTracker = requestTracker;

    requestTracker.register(this);
  }

  @Override
  public void reply(Response<ByteString> message) {
    doReply(message);
  }

  @Override
  public void drop() {
    final boolean removed = requestTracker.remove(this);
    if (removed) {
      super.drop();
    }
  }

  @Override
  public void incrementDownstreamRequests() {
  }

  private boolean doReply(Response<ByteString> message) {
    final boolean removed = requestTracker.remove(this);
    if (removed) {
      super.reply(message);
    }
    // TODO: how to log this?
//    else {
//      logRequest("DROPPED");
//    }
    return removed;
  }
}

@@ -973,89 +973,8 @@
   %7D%0A
-    // TODO: how to log this?%0A//    else %7B%0A//      logRequest(%22DROPPED%22);%0A//    %7D
 %0A   

remove comment about logging dropped requests