Fix wrong date/time for commits in refs/meta/config branch

When the refs/meta/config branch is modified using the PutConfig REST
endpoint (e.g. when changing the project configuration in the web UI)
the commit date/time is wrong. Instead of the actual date/time the
date/time of the last Gerrit server start is used. This is because
MetaDataUpdate.User which gets the GerritPersonIdent injected is kept
as member in the PutConfig singleton and the date/time for commits in
the refs/meta/config branch is retrieved from that GerritPersonIdent
instance which is only created once when the PutConfig singleton is
instantiated.

Bug: Issue 3371
Change-Id: I85424db74e8609c8e4117e8db78a80730c29ace1
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2015-07-01 16:19:52 +02:00
parent e32f360238
commit e53859a0da

View File

@@ -74,7 +74,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
}
private final MetaDataUpdate.User metaDataUpdateFactory;
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
private final ProjectCache projectCache;
private final GitRepositoryManager gitMgr;
private final ProjectState.Factory projectStateFactory;
@@ -87,7 +87,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
private final ChangeHooks hooks;
@Inject
PutConfig(MetaDataUpdate.User metaDataUpdateFactory,
PutConfig(Provider<MetaDataUpdate.User> metaDataUpdateFactory,
ProjectCache projectCache,
GitRepositoryManager gitMgr,
ProjectState.Factory projectStateFactory,
@@ -131,7 +131,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
final MetaDataUpdate md;
try {
md = metaDataUpdateFactory.create(projectName);
md = metaDataUpdateFactory.get().create(projectName);
} catch (RepositoryNotFoundException notFound) {
throw new ResourceNotFoundException(projectName.get());
} catch (IOException e) {