Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-06-03 07:05:01 -0400
committerFlorian Waibel2015-06-03 07:05:01 -0400
commit4d499205143a70ac8f5627df78845923b1edcbe7 (patch)
tree1939c3d53dd33cf451f17ea31b7400ada21f44c2
parentc88bf1cf41c70d3a42449d340125a2c776161546 (diff)
downloadorg.eclipse.virgo.kernel-4d499205143a70ac8f5627df78845923b1edcbe7.tar.gz
org.eclipse.virgo.kernel-4d499205143a70ac8f5627df78845923b1edcbe7.tar.xz
org.eclipse.virgo.kernel-4d499205143a70ac8f5627df78845923b1edcbe7.zip
Adds explicit encoding in SynteticContextBundleCreatingTransformer and SimpleFileHelpAccessor
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java8
-rw-r--r--org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/internal/help/SimpleFileHelpAccessor.java23
2 files changed, 11 insertions, 20 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
index 2201f12d..5db3ad20 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
@@ -12,6 +12,8 @@
package org.eclipse.virgo.kernel.install.pipeline.stage.transform.internal;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
@@ -21,8 +23,6 @@ import java.util.jar.JarFile;
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.nano.deployer.api.core.FatalDeploymentException;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentity;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentityDeterminer;
import org.eclipse.virgo.kernel.install.artifact.ArtifactStorage;
@@ -34,6 +34,8 @@ import org.eclipse.virgo.kernel.install.artifact.internal.ArtifactStorageFactory
import org.eclipse.virgo.kernel.install.artifact.internal.scoping.ScopeNameFactory;
import org.eclipse.virgo.kernel.install.environment.InstallEnvironment;
import org.eclipse.virgo.kernel.install.pipeline.stage.transform.Transformer;
+import org.eclipse.virgo.nano.deployer.api.core.DeploymentException;
+import org.eclipse.virgo.nano.deployer.api.core.FatalDeploymentException;
import org.eclipse.virgo.util.common.GraphNode;
import org.eclipse.virgo.util.io.IOUtils;
import org.eclipse.virgo.util.osgi.manifest.BundleManifest;
@@ -122,7 +124,7 @@ final class SyntheticContextBundleCreatingTransformer implements Transformer, Sc
private void writeSyntheticContextBundle(BundleManifest syntheticContextBundleManifest, ArtifactFS artifactFS) {
ArtifactFSEntry entry = artifactFS.getEntry(JarFile.MANIFEST_NAME);
- Writer manifestWriter = new OutputStreamWriter(entry.getOutputStream());
+ Writer manifestWriter = new OutputStreamWriter(entry.getOutputStream(), UTF_8);
try {
syntheticContextBundleManifest.write(manifestWriter);
} catch (IOException ioe) {
diff --git a/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/internal/help/SimpleFileHelpAccessor.java b/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/internal/help/SimpleFileHelpAccessor.java
index e8a2c215..729e714b 100644
--- a/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/internal/help/SimpleFileHelpAccessor.java
+++ b/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/internal/help/SimpleFileHelpAccessor.java
@@ -11,6 +11,8 @@
package org.eclipse.virgo.shell.internal.help;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -25,8 +27,6 @@ import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.eclipse.virgo.util.io.IOUtils;
-
/**
* Implementation of {@link HelpAccessor} which searches for a simple text file resource in the bundle of the class.
* <p/>
@@ -53,16 +53,12 @@ public class SimpleFileHelpAccessor implements HelpAccessor {
* {@inheritDoc}
*/
public List<String> getDetailedHelp(Class<?> clazz) {
- BufferedReader readFileIn = null;
- try {
- readFileIn = this.helpResourceReader(clazz);
+ try (BufferedReader readFileIn = this.helpResourceReader(clazz)) {
if (readFileIn != null) {
return readAllButFirstHelpLines(readFileIn);
}
} catch (IOException ioe) {
logger.error(String.format("Exception reading help resource for class '%s'.", clazz.getCanonicalName()), ioe);
- } finally {
- IOUtils.closeQuietly(readFileIn);
}
return Collections.emptyList();
}
@@ -71,16 +67,12 @@ public class SimpleFileHelpAccessor implements HelpAccessor {
* {@inheritDoc}
*/
public String getSummaryHelp(Class<?> clazz) {
- BufferedReader readFileIn = null;
- try {
- readFileIn = this.helpResourceReader(clazz);
+ try (BufferedReader readFileIn = this.helpResourceReader(clazz)) {
if (readFileIn != null) {
return readFirstHelpLine(readFileIn);
}
} catch (IOException ioe) {
logger.error(String.format("Exception reading help resource for class '%s'.", clazz.getCanonicalName()), ioe);
- } finally {
- IOUtils.closeQuietly(readFileIn);
}
return null;
}
@@ -128,13 +120,10 @@ public class SimpleFileHelpAccessor implements HelpAccessor {
String fileResourceName = new StringBuffer(className).append(HELP_ACCESSOR_RESOURCE_EXTENSION).toString();
URL resourceUrl = this.helpResourceUrl(clazz, fileResourceName);
if (resourceUrl != null) {
- InputStream resourceIn = null;
- try {
- resourceIn = resourceUrl.openStream();
- readFileIn = new BufferedReader(new InputStreamReader(resourceIn));
+ try (InputStream resourceIn = resourceUrl.openStream()) {
+ readFileIn = new BufferedReader(new InputStreamReader(resourceIn, UTF_8));
} catch (IOException ioe) {
logger.error(String.format("Exception reading help resource '%s'.", resourceUrl), ioe);
- IOUtils.closeQuietly(resourceIn);
return null;
}
}

Back to the top