summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Bull2012-08-29 14:25:20 (EDT)
committerIan Bull2012-08-29 14:25:20 (EDT)
commitdf9a9a4cf68dc044a42ce298beefe32c151525e1 (patch)
tree62303698553b43b12c5e5d84d237fdc5d91b7ef1
parent959c4dab9762c898467cac808cd5fe35362cb07c (diff)
downloadrt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.zip
rt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.tar.gz
rt.equinox.p2-df9a9a4cf68dc044a42ce298beefe32c151525e1.tar.bz2
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 87cf474..c1cddee 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 1f03639..f72ae68 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 0201e4e..ad4de6f 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 1eff48b..45a196a 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 0085466..1f863e8 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 6b4d98b..425c5e1 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();
+ }
}
/*