Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-06-03 08:56:59 -0400
committerFlorian Waibel2015-06-03 09:06:49 -0400
commit31b08a89ee1ef82f2cacc093af51873a765f2638 (patch)
treec89e3391d9cd6bf014b1db16c0c2d72d0bb570a2
parent4d499205143a70ac8f5627df78845923b1edcbe7 (diff)
downloadorg.eclipse.virgo.kernel-31b08a89ee1ef82f2cacc093af51873a765f2638.tar.gz
org.eclipse.virgo.kernel-31b08a89ee1ef82f2cacc093af51873a765f2638.tar.xz
org.eclipse.virgo.kernel-31b08a89ee1ef82f2cacc093af51873a765f2638.zip
Replaces code using default encoding with code using explicitly UTF-8
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/BundleInstallArtifactFactory.java38
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java11
2 files changed, 22 insertions, 27 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/BundleInstallArtifactFactory.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/BundleInstallArtifactFactory.java
index 42730f51..ece49d87 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/BundleInstallArtifactFactory.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/BundleInstallArtifactFactory.java
@@ -11,29 +11,28 @@
package org.eclipse.virgo.kernel.install.artifact.internal.bundle;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.jar.JarFile;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Version;
-
-
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFS;
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFSEntry;
-import org.eclipse.virgo.nano.deployer.api.core.DeploymentException;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentity;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentityDeterminer;
import org.eclipse.virgo.kernel.install.artifact.ArtifactStorage;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.internal.ArtifactStateMonitor;
-import org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor;
import org.eclipse.virgo.kernel.install.artifact.internal.InstallArtifactRefreshHandler;
+import org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor;
import org.eclipse.virgo.medic.eventlog.EventLogger;
-import org.eclipse.virgo.util.io.IOUtils;
+import org.eclipse.virgo.nano.deployer.api.core.DeploymentException;
import org.eclipse.virgo.util.osgi.manifest.BundleManifest;
import org.eclipse.virgo.util.osgi.manifest.BundleManifestFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
/**
* A factory for creating {@link BundleInstallArtifact} instances.
@@ -54,9 +53,9 @@ final class BundleInstallArtifactFactory {
private final InstallArtifactRefreshHandler refreshHandler;
private final BundleDriverFactory bundleDriverFactory;
-
+
private final EventLogger eventLogger;
-
+
private final ArtifactIdentityDeterminer identityDeterminer;
BundleInstallArtifactFactory(BundleContext kernelBundleContext, InstallArtifactRefreshHandler refreshHandler,
@@ -68,18 +67,20 @@ final class BundleInstallArtifactFactory {
this.identityDeterminer = identityDeterminer;
}
- BundleInstallArtifact createBundleInstallArtifact(ArtifactIdentity identity, ArtifactStorage artifactStorage, String repositoryName) throws DeploymentException {
+ BundleInstallArtifact createBundleInstallArtifact(ArtifactIdentity identity, ArtifactStorage artifactStorage, String repositoryName)
+ throws DeploymentException {
ArtifactStateMonitor artifactStateMonitor = new StandardArtifactStateMonitor(this.kernelBundleContext);
StandardBundleDriver bundleDriver = this.bundleDriverFactory.createBundleDriver(identity, artifactStateMonitor);
- BundleManifest bundleManifest = retrieveArtifactFSManifest(artifactStorage.getArtifactFS());
+ BundleManifest bundleManifest = retrieveArtifactFSManifest(artifactStorage.getArtifactFS());
+
+ StandardBundleInstallArtifact bundleInstallArtifact = new StandardBundleInstallArtifact(identity, bundleManifest, artifactStorage,
+ bundleDriver, artifactStateMonitor, this.refreshHandler, repositoryName, this.eventLogger, this.identityDeterminer);
- StandardBundleInstallArtifact bundleInstallArtifact = new StandardBundleInstallArtifact(identity, bundleManifest, artifactStorage, bundleDriver, artifactStateMonitor, this.refreshHandler, repositoryName, this.eventLogger, this.identityDeterminer);
+ // TODO: need to set identity version from bundleManifest etc. Best to use supertype method.
- //TODO: need to set identity version from bundleManifest etc. Best to use supertype method.
-
bundleDriver.setInstallArtifact(bundleInstallArtifact);
return bundleInstallArtifact;
@@ -88,13 +89,8 @@ final class BundleInstallArtifactFactory {
private BundleManifest retrieveArtifactFSManifest(ArtifactFS artifactFS) throws DeploymentException {
ArtifactFSEntry manifestEntry = artifactFS.getEntry(JarFile.MANIFEST_NAME);
if (manifestEntry != null && manifestEntry.exists()) {
- try {
- Reader manifestReader = new InputStreamReader(manifestEntry.getInputStream());
- try {
- return BundleManifestFactory.createBundleManifest(manifestReader);
- } finally {
- IOUtils.closeQuietly(manifestReader);
- }
+ try (Reader manifestReader = new InputStreamReader(manifestEntry.getInputStream(), UTF_8)) {
+ return BundleManifestFactory.createBundleManifest(manifestReader);
} catch (IOException ioe) {
throw new DeploymentException("Failed to read manifest for bundle from " + artifactFS, ioe);
}
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
index ae2908f3..0e679000 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
@@ -11,6 +11,8 @@
package org.eclipse.virgo.kernel.userregion.internal.equinox;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -27,11 +29,10 @@ import java.util.jar.JarFile;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
-
+import org.eclipse.virgo.kernel.equinox.extensions.hooks.BundleFileWrapper;
import org.eclipse.virgo.kernel.osgi.framework.ImportExpander;
import org.eclipse.virgo.kernel.osgi.framework.ManifestTransformer;
import org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyDependenciesException;
-import org.eclipse.virgo.kernel.equinox.extensions.hooks.BundleFileWrapper;
import org.eclipse.virgo.util.osgi.manifest.BundleManifest;
import org.eclipse.virgo.util.osgi.manifest.BundleManifestFactory;
@@ -142,10 +143,8 @@ public class TransformedManifestProvidingBundleFileWrapper implements BundleFile
BundleManifest originalManifest;
if (entry != null) {
- try {
- InputStreamReader manifestReader = new InputStreamReader(entry.getInputStream());
+ try (InputStreamReader manifestReader = new InputStreamReader(entry.getInputStream(), UTF_8)) {
originalManifest = BundleManifestFactory.createBundleManifest(manifestReader);
- manifestReader.close();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
@@ -241,7 +240,7 @@ public class TransformedManifestProvidingBundleFileWrapper implements BundleFile
private TransformedManifestBundleEntry(BundleManifest transformedManifest) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- transformedManifest.write(new OutputStreamWriter(baos));
+ transformedManifest.write(new OutputStreamWriter(baos, UTF_8));
this.manifestBytes = baos.toByteArray();

Back to the top