Skip to content

Commit

Permalink
Added some logging in the DispatchServiceManager that monitors whethe…
Browse files Browse the repository at this point in the history
…r a call is being made for the current project or a different project
  • Loading branch information
matthewhorridge committed Jun 3, 2024
1 parent 8c8528e commit 34178e4
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.web.bindery.event.shared.EventBus;
Expand All @@ -31,6 +32,7 @@
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkNotNull;
Expand Down Expand Up @@ -126,6 +128,7 @@ public <A extends Action<R>, R extends Result> void execute(A action, final Disp
callback.handleSubmittedForExecution();
if(action instanceof HasProjectId) {
ProjectId projectId = ((HasProjectId) action).getProjectId();
checkMakingACallForCurrentProject(projectId);
ResultCache resultCache = getResultCache(projectId, eventBus);
Optional<R> result = resultCache.getCachedResult(action);
if (result.isPresent()) {
Expand All @@ -145,6 +148,24 @@ public <A extends Action<R>, R extends Result> void execute(A action, final Disp
// }
}

private void checkMakingACallForCurrentProject(ProjectId projectId) {
Place place = placeController.getWhere();
if(place instanceof HasProjectId) {
ProjectId placeProjectId = ((HasProjectId) place).getProjectId();
if(!placeProjectId.equals(projectId)) {
logCurrentStack();
}
}
}

private static void logCurrentStack() {
try {
throw new RuntimeException("Mismatch");
} catch (RuntimeException e) {
logger.log(Level.WARNING, "Mismatch of project Ids. If not deliberate this may indicated a bug somewhere.", e);
}
}

@SuppressWarnings("unchecked")
private <A extends Action<R>, R extends Result> void execAction(A action, DispatchServiceCallback<R> callback) {
requestCount++;
Expand Down

0 comments on commit 34178e4

Please sign in to comment.