diff options
author | Alexander Kurtakov | 2018-01-19 06:30:56 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-01-19 06:30:56 +0000 |
commit | 33c9312f4043bb01cfb6e96abde313090d214dcd (patch) | |
tree | 891767f753a91d87066728997514592d7a1d51db | |
parent | f71d9b28096a847fe6b14e62578154f35a150f60 (diff) | |
download | rt.equinox.bundles-33c9312f4043bb01cfb6e96abde313090d214dcd.tar.gz rt.equinox.bundles-33c9312f4043bb01cfb6e96abde313090d214dcd.tar.xz rt.equinox.bundles-33c9312f4043bb01cfb6e96abde313090d214dcd.zip |
Bug 530015 - Use StandardCharsets in console bundlesI20180119-2000
Change-Id: I2c1e775f33e7b25897a641b2d426b39cfcd26471
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
2 files changed, 7 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java index be0f1a843..09cd0064c 100644 --- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java +++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2011, 2017 Gunnar Wagenknecht and others. + * Copyright (c) 2011, 2018 Gunnar Wagenknecht and others. * All rights reserved. * * This program and the accompanying materials are made available under the terms of the @@ -14,9 +14,9 @@ package org.eclipse.equinox.console.internal.ssh; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; @@ -62,19 +62,11 @@ public class AuthorizedKeys { private static final String NEWLINE = "\n"; private static byte[] asBytes(final String string) { - try { - return string.getBytes("UTF-8"); - } catch (final UnsupportedEncodingException e) { - return string.getBytes(); - } + return string.getBytes(StandardCharsets.UTF_8); } private static String asString(final byte[] bytes) { - try { - return new String(bytes, "UTF-8"); - } catch (final UnsupportedEncodingException e) { - return new String(bytes); - } + return new String(bytes, StandardCharsets.UTF_8); } public static void main(final String[] args) { diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java index 1e304b593..820262e99 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 SAP AG + * Copyright (c) 2010, 2018 SAP AG * 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,7 +11,7 @@ package org.eclipse.equinox.console.common; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; /** @@ -37,11 +37,7 @@ public class HistoryHolder { } public synchronized void add(byte[] data) { - try { - data = new String(data, "US-ASCII").trim().getBytes("US-ASCII"); - } catch (UnsupportedEncodingException e) { - - } + data = new String(data, StandardCharsets.US_ASCII).trim().getBytes(StandardCharsets.US_ASCII); if (data.length == 0) { pos = size; return; |