Skip to content

Is there a reason for 'PendingFutures' being a static class instead of being Objectify bound? #326

@nbali

Description

@nbali

Scenario that triggered this issue:

We have a Objectify context properly initialized by ObjectifyFilter for the whole request. We are using a highly volatile entity. During that request after some execution and already having that entity in the objectify local Session cache we need the current global state of that entity from the datastore/memcache. Doesn't matter if it is memcached or not, we just want to skip the local cache. Also we don't need the overhead a transaction provides.

We solved this by using

		try (Closeable closeable = ObjectifyService.begin()) {
			return ofy().load().type(c).id(id).now();
		}

The problem we faced is that during the close() method PendingFutures.completeAllPendingFutures(); is called which is a static class with a thread-local collection of pending futures. This call waits for a Future.get on all of them. It even waits for the requests started by the external Objectify context. I think it should only wait the requests launched with the "current" Objectify instance, and the futures should be collected to where they belong.

Am I missing a point here on the why?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions