[513669] Refactor code from P2 Management working set after SonarQube
analysis.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=513669
Change-Id: I05348c9dfd05a93a7fbdfc189678da6b1db0b134
Signed-off-by: William Enright <william.enright@ericsson.com>
diff --git a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
index 38b0e35..f5f189d 100644
--- a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
+++ b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
@@ -832,7 +832,7 @@
// And will preserve the existing line feed convention if we need to add new lines.
URI baseURI = URI.createFileURI(installFolder.toString()).appendSegment("");
StringBuilder newContents = new StringBuilder();
- String nl = null;
+ String nl;
for (Map.Entry<String, String> entry : map.entrySet())
{
// The keys will generally include the line feed character, so we trim that off when inspecting the key.
@@ -975,7 +975,7 @@
{
URI configurationFolderURI = URI.createFileURI(configurationFolder.toString());
Configuration configuration = Configuration.load(platformXML, null);
- boolean changed = true;
+ boolean changed = false;
for (Site site : configuration.getSites())
{
// If the site URI is of the form file:../<path> then we need to make it absolute.
diff --git a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/CachingRepositoryManager.java b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/CachingRepositoryManager.java
index e3d1d46..f5500a7 100644
--- a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/CachingRepositoryManager.java
+++ b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/CachingRepositoryManager.java
@@ -226,7 +226,7 @@
}
// Eagerly cleanup missing system repositories.
- if (Boolean.valueOf(delegate.getRepositoryProperty(location, IRepository.PROP_SYSTEM)).booleanValue())
+ if (Boolean.parseBoolean(delegate.getRepositoryProperty(location, IRepository.PROP_SYSTEM)))
{
delegate.removeRepository(location);
}
@@ -949,7 +949,7 @@
String locationString = repositoryURI.toString();
if (!locationString.endsWith("/"))
{
- locationString += '/';
+ locationString += Character.toString('/');
}
mirrorActivities = new MirrorActivity[] { new MirrorActivity(locationString) };
@@ -1130,7 +1130,7 @@
failures.incrementAndGet();
}
- public long getSpeed()
+ public synchronized long getSpeed()
{
return speed.get();
}
diff --git a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/P2IndexImpl.java b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/P2IndexImpl.java
index c7db2e2..65858b1 100644
--- a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/P2IndexImpl.java
+++ b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/P2IndexImpl.java
@@ -108,7 +108,7 @@
if (refreshed)
{
File validityFile = getCapabilitiesValidityFile();
- IOUtil.writeLines(validityFile, "UTF-8", Collections.singletonList("" + (System.currentTimeMillis() + refreshHours * 60 * 60 * 1000)));
+ IOUtil.writeLines(validityFile, "UTF-8", Collections.singletonList("" + Long.toString(System.currentTimeMillis() + refreshHours * 60 * 60 * 1000)));
}
}
catch (Exception ex)
@@ -165,7 +165,7 @@
if (refreshed)
{
File validityFile = getRepositoriesValidityFile();
- IOUtil.writeLines(validityFile, "UTF-8", Collections.singletonList("" + (System.currentTimeMillis() + refreshHours * 60 * 60 * 1000)));
+ IOUtil.writeLines(validityFile, "UTF-8", Collections.singletonList("" + Long.toString(System.currentTimeMillis() + refreshHours * 60 * 60 * 1000)));
}
Map<RepositoryImpl, List<Integer>> composedRepositories = new HashMap<RepositoryImpl, List<Integer>>();
diff --git a/plugins/org.eclipse.oomph.p2.ui/src/org/eclipse/oomph/p2/internal/ui/RepositoryManager.java b/plugins/org.eclipse.oomph.p2.ui/src/org/eclipse/oomph/p2/internal/ui/RepositoryManager.java
index 7131918..8dd6265 100644
--- a/plugins/org.eclipse.oomph.p2.ui/src/org/eclipse/oomph/p2/internal/ui/RepositoryManager.java
+++ b/plugins/org.eclipse.oomph.p2.ui/src/org/eclipse/oomph/p2/internal/ui/RepositoryManager.java
@@ -160,7 +160,7 @@
boolean changed = false;
synchronized (repositories)
{
- if (repositories.size() == 0 || !repositories.getFirst().equals(repository))
+ if (repositories.isEmpty() || !repositories.getFirst().equals(repository))
{
repositories.remove(repository);
repositories.addFirst(repository);