From 77a452d96f8fe6ae50bfd9e67df8da62f3973ab3 Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Sat, 2 Mar 2024 18:09:14 +0100 Subject: [PATCH] [#37] run clean up... for all Gitlab projects --- .../core/test/RestfulGitlabClientTest.java | 2 +- .../gitlab/core/GitlabCoreActivator.java | 3 +- .../core/GitlabRepositoryConnector.java | 33 +++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core.test/src/org/eclipse/mylyn/gitlab/core/test/RestfulGitlabClientTest.java b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core.test/src/org/eclipse/mylyn/gitlab/core/test/RestfulGitlabClientTest.java index cdccc2d373..a971752f75 100644 --- a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core.test/src/org/eclipse/mylyn/gitlab/core/test/RestfulGitlabClientTest.java +++ b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core.test/src/org/eclipse/mylyn/gitlab/core/test/RestfulGitlabClientTest.java @@ -144,7 +144,7 @@ void testGetNamespaces() throws Exception { } techUsers.sort(Comparator.naturalOrder()); String fName = "testdata/getNamespaces" + (techUsers.size() > 0 ? "_" : "") + String.join("_", techUsers) - + ".json"; + + ".json"; String actual = new GsonBuilder().setPrettyPrinting().create().toJson(resultElement); String expected = IOUtils.toString(CommonTestUtil.getResource(this, fName), Charset.defaultCharset()); diff --git a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/gitlab/core/GitlabCoreActivator.java b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/gitlab/core/GitlabCoreActivator.java index 7e9e680295..cff17e63cc 100644 --- a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/gitlab/core/GitlabCoreActivator.java +++ b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/gitlab/core/GitlabCoreActivator.java @@ -98,8 +98,7 @@ public void start(BundleContext context) throws Exception { DEBUG_REGISTRATION = context.registerService(DebugOptionsListener.class, options -> { boolean debugCore = options.getBooleanOption(PLUGIN_ID + DEBUG, false); DEBUG_TRACE = options.newDebugTrace(PLUGIN_ID); - DEBUG_REPOSITORY_CONNECTOR = debugCore - && options.getBooleanOption(PLUGIN_ID + REPOSITORY_CONNECTOR, false); + DEBUG_REPOSITORY_CONNECTOR = debugCore && options.getBooleanOption(PLUGIN_ID + REPOSITORY_CONNECTOR, false); DEBUG_REST_CLIENT = debugCore && options.getBooleanOption(PLUGIN_ID + REST_CLIENT, false); DEBUG_REST_CLIENT_TRACE = debugCore && options.getBooleanOption(PLUGIN_ID + REST_CLIENT_TRACE, false); }, properties); diff --git a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/internal/gitlab/core/GitlabRepositoryConnector.java b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/internal/gitlab/core/GitlabRepositoryConnector.java index bffc776f42..b4f6ded2c4 100644 --- a/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/internal/gitlab/core/GitlabRepositoryConnector.java +++ b/mylyn.tasks/connectors/gitlab/org.eclipse.mylyn.gitlab.core/src/org/eclipse/mylyn/internal/gitlab/core/GitlabRepositoryConnector.java @@ -14,7 +14,6 @@ package org.eclipse.mylyn.internal.gitlab.core; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -119,18 +118,9 @@ private boolean ignoredProperty(String propertyName) { return false; } - private final PropertyChangeListener repositoryChangeListener4ConfigurationCache = new PropertyChangeListener() { + private PropertyChangeListener repositoryChangeListener4ConfigurationCache = null; - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (ignoredProperty(evt.getPropertyName()) - || evt.getPropertyName().equals("org.eclipse.mylyn.tasklist.repositories.password")) { //$NON-NLS-1$ - return; - } - TaskRepository taskRepository = (TaskRepository) evt.getSource(); - configurationCache.invalidate(new RepositoryKey(taskRepository)); - } - }; + private PropertyChangeListener repositoryChangeListener4ClientCache; protected Caffeine createCacheBuilder(Duration expireAfterWriteDuration, Duration refreshAfterWriteDuration) { @@ -151,6 +141,20 @@ public GitlabRepositoryConnector(Duration refreshAfterWriteDuration) { repository.addChangeListener(repositoryChangeListener4ConfigurationCache); return Optional.ofNullable(client.getConfiguration(key.getRepository(), context.get())); }); + + repositoryChangeListener4ClientCache = evt -> { + TaskRepository taskRepository = (TaskRepository) evt.getSource(); + clientCache.invalidate(new RepositoryKey(taskRepository)); + }; + + repositoryChangeListener4ConfigurationCache = evt -> { + if (ignoredProperty(evt.getPropertyName()) + || evt.getPropertyName().equals("org.eclipse.mylyn.tasklist.repositories.password")) { //$NON-NLS-1$ + return; + } + TaskRepository taskRepository = (TaskRepository) evt.getSource(); + configurationCache.invalidate(new RepositoryKey(taskRepository)); + }; } public GitlabConfiguration getRepositoryConfiguration(TaskRepository repository) throws CoreException { @@ -310,11 +314,6 @@ public GitlabRestClient getClient(TaskRepository repository) throws CoreExceptio return clientCache.get(new RepositoryKey(repository)); } - private final PropertyChangeListener repositoryChangeListener4ClientCache = evt -> { - TaskRepository taskRepository = (TaskRepository) evt.getSource(); - this.clientCache.invalidate(new RepositoryKey(taskRepository)); - }; - private final LoadingCache clientCache = Caffeine.newBuilder() .expireAfterAccess(CLIENT_CACHE_DURATION.getValue(), CLIENT_CACHE_DURATION.getUnit()) .build(key -> {