Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Bull2012-08-29 18:25:20 +0000
committerIan Bull2012-08-29 18:25:20 +0000
commitdf9a9a4cf68dc044a42ce298beefe32c151525e1 (patch)
tree62303698553b43b12c5e5d84d237fdc5d91b7ef1
parent959c4dab9762c898467cac808cd5fe35362cb07c (diff)
downloadrt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.tar.gz
rt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.tar.xz
rt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.zip
Bug 381673: Fixes a few compile warningsv20120829-182520
This fixes 2 types of compile warnings. 1. Stream not closed warnings. 2. Unused object warnings
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/BatchExecuteMetadataRepositoryTest.java14
6 files changed, 28 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
index 87cf474b5..c1cddeeeb 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
@@ -456,9 +456,8 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
jarFile.getParentFile().mkdirs();
jarFile.createNewFile();
}
- JarOutputStream jOs = new JarOutputStream(new FileOutputStream(jarFile));
- jOs.putNextEntry(new JarEntry(new Path(artifactsFile.getAbsolutePath()).lastSegment()));
- os = jOs;
+ os = new JarOutputStream(new FileOutputStream(jarFile));
+ ((JarOutputStream) os).putNextEntry(new JarEntry(new Path(artifactsFile.getAbsolutePath()).lastSegment()));
}
super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis()));
new CompositeRepositoryIO().write(toState(), os, PI_REPOSITORY_TYPE);
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 1f036394b..f72ae6847 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -1238,9 +1238,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
mkdirs(jarFile.getParentFile());
jarFile.createNewFile();
}
- JarOutputStream jOs = new JarOutputStream(new FileOutputStream(jarFile));
- jOs.putNextEntry(new JarEntry(new Path(artifactsFile.getAbsolutePath()).lastSegment()));
- os = jOs;
+ os = new JarOutputStream(new FileOutputStream(jarFile));
+ ((JarOutputStream) os).putNextEntry(new JarEntry(new Path(artifactsFile.getAbsolutePath()).lastSegment()));
}
super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis()), new NullProgressMonitor());
new SimpleArtifactRepositoryIO(getProvisioningAgent()).write(this, os);
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
index 0201e4e22..ad4de6f8e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
@@ -322,9 +322,8 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
jarFile.createNewFile();
}
JarEntry jarEntry = new JarEntry(file.getName());
- JarOutputStream jOutput = new JarOutputStream(new FileOutputStream(jarFile));
- jOutput.putNextEntry(jarEntry);
- output = jOutput;
+ output = new JarOutputStream(new FileOutputStream(jarFile));
+ ((JarOutputStream) output).putNextEntry(jarEntry);
}
super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis()));
new CompositeRepositoryIO().write(toState(), output, PI_REPOSITORY_TYPE);
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
index 1eff48bb3..45a196a07 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
@@ -299,9 +299,8 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
jarFile.createNewFile();
}
JarEntry jarEntry = new JarEntry(file.getName());
- JarOutputStream jOutput = new JarOutputStream(new FileOutputStream(jarFile));
- jOutput.putNextEntry(jarEntry);
- output = jOutput;
+ output = new JarOutputStream(new FileOutputStream(jarFile));
+ ((JarOutputStream) output).putNextEntry(jarEntry);
}
super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis()), new NullProgressMonitor());
new MetadataRepositoryIO(getProvisioningAgent()).write(this, output);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java
index 0085466a0..1f863e802 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java
@@ -187,10 +187,16 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest
boolean fileContainsString(URI location, String string) throws IOException {
StringBuffer buffer = new StringBuffer();
- BufferedReader reader = new BufferedReader(new FileReader(new File(location)));
- while (reader.ready())
- buffer.append(reader.readLine());
- return buffer.toString().contains(string);
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(new File(location)));
+ while (reader.ready())
+ buffer.append(reader.readLine());
+ return buffer.toString().contains(string);
+ } finally {
+ if (reader != null)
+ reader.close();
+ }
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/BatchExecuteMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/BatchExecuteMetadataRepositoryTest.java
index 6b4d98b4b..425c5e1ad 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/BatchExecuteMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/BatchExecuteMetadataRepositoryTest.java
@@ -40,10 +40,16 @@ public class BatchExecuteMetadataRepositoryTest extends AbstractProvisioningTest
boolean fileContainsString(URI location, String string) throws IOException {
StringBuffer buffer = new StringBuffer();
- BufferedReader reader = new BufferedReader(new FileReader(new File(location)));
- while (reader.ready())
- buffer.append(reader.readLine());
- return buffer.toString().contains(string);
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(new File(location)));
+ while (reader.ready())
+ buffer.append(reader.readLine());
+ return buffer.toString().contains(string);
+ } finally {
+ if (reader != null)
+ reader.close();
+ }
}
/*

Back to the top