Skip to content

Commit

Permalink
[#37] run clean up... for all Gitlab projects
Browse files Browse the repository at this point in the history
  • Loading branch information
BeckerFrank authored and ruspl-afed committed Mar 4, 2024
1 parent 2c8c45f commit 77a452d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Object, Object> createCacheBuilder(Duration expireAfterWriteDuration,
Duration refreshAfterWriteDuration) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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<RepositoryKey, GitlabRestClient> clientCache = Caffeine.newBuilder()
.expireAfterAccess(CLIENT_CACHE_DURATION.getValue(), CLIENT_CACHE_DURATION.getUnit())
.build(key -> {
Expand Down

0 comments on commit 77a452d

Please sign in to comment.