Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-07-05 07:40:50 -0400
committerAlexander Kurtakov2017-07-05 07:43:07 -0400
commit25a924b8f6a02aebf1e560f61f1640af50b53fb3 (patch)
treec2cf3f3891005e49cb74512391e18f07032c49d1
parentc85cb5f21d55784f3e9cbb7e195020338598f4f0 (diff)
downloadrt.equinox.framework-I20170710-2000.tar.gz
rt.equinox.framework-I20170710-2000.tar.xz
rt.equinox.framework-I20170710-2000.zip
Faster and less error prone code. Change-Id: Ia49c46c212d92a144405fdc2635347d2c3eb49b9 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java10
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java10
5 files changed, 14 insertions, 33 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java
index 6d2378821..9f6c704bd 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java
@@ -11,6 +11,7 @@
package org.eclipse.osgi.internal.debug;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
@@ -604,12 +605,7 @@ class EclipseDebugTrace implements DebugTrace {
* @return A Writer for the given OutputStream
*/
private Writer logForStream(OutputStream output) {
-
- try {
- return new BufferedWriter(new OutputStreamWriter(output, "UTF-8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- return new BufferedWriter(new OutputStreamWriter(output));
- }
+ return new BufferedWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8));
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java
index b6fd06b3c..f005e47fb 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2016 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.osgi.internal.framework;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.osgi.internal.debug.Debug;
@@ -99,12 +100,7 @@ public class AliasMapper {
*/
private static Map<String, Collection<String>> initAliases(InputStream in, Map<String, Collection<String>> aliasTable, Map<String, String> canonicalTable) {
try {
- BufferedReader br;
- try {
- br = new BufferedReader(new InputStreamReader(in, "UTF8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- br = new BufferedReader(new InputStreamReader(in));
- }
+ BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
Map<String, Set<String>> multiMaster = new HashMap<>();
while (true) {
String line = br.readLine();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java
index c07307a3e..3bdc0e133 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2015 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@ package org.eclipse.osgi.internal.log;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
import org.eclipse.equinox.log.*;
@@ -445,11 +446,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter {
* @return a Writer for the given OutputStream
*/
private Writer logForStream(OutputStream output) {
- try {
- return new BufferedWriter(new OutputStreamWriter(output, "UTF-8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- return new BufferedWriter(new OutputStreamWriter(output));
- }
+ return new BufferedWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8));
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
index 3a05f2977..e156d6d71 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.osgi.internal.permadmin;
import java.io.*;
import java.math.BigInteger;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.cert.*;
import java.util.*;
@@ -427,12 +428,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi
try {
in = new DataInputStream(resource.openStream());
List<PermissionInfo> permissions = new ArrayList<>();
- BufferedReader reader;
- try {
- reader = new BufferedReader(new InputStreamReader(in, "UTF8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- reader = new BufferedReader(new InputStreamReader(in));
- }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
while (true) {
String line = reader.readLine();
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
index 6fd13b2e4..b8faeb4a3 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2016 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
package org.eclipse.osgi.framework.internal.reliablefile;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
@@ -822,12 +823,7 @@ public class ReliableFile {
crc.update(data, 0, 16); // update crc w/ sig bytes
return FILETYPE_NOSIGNATURE;
}
- long crccmp;
- try {
- crccmp = Long.valueOf(new String(data, 4, 8, "UTF-8"), 16).longValue(); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- crccmp = Long.valueOf(new String(data, 4, 8), 16).longValue();
- }
+ long crccmp = Long.valueOf(new String(data, 4, 8, StandardCharsets.UTF_8), 16).longValue();
if (crccmp == crc.getValue()) {
return FILETYPE_VALID;
}

Back to the top