summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-04-18 12:38:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-04-18 12:38:02 +0000
commit979467bac9e1f034f08e8b1e34a1e2421cc0d5e8 (patch)
tree0931054dc28f99ef5c99a0bbb6631dbced610518
parent8acbb1e4ca98e2f4cac0bc7972d860daf0636e8d (diff)
parentb3dccbbebc2e3de0d45ed26bdffa58a2797e07d6 (diff)
downloadbouncycastle-979467bac9e1f034f08e8b1e34a1e2421cc0d5e8.tar.gz
Merge "Revert "Strings: hardcode "\n" as the line separator""
-rw-r--r--bcprov/src/main/java/org/bouncycastle/util/Strings.java65
1 files changed, 29 insertions, 36 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/util/Strings.java b/bcprov/src/main/java/org/bouncycastle/util/Strings.java
index a9bbc9fc..a42830b3 100644
--- a/bcprov/src/main/java/org/bouncycastle/util/Strings.java
+++ b/bcprov/src/main/java/org/bouncycastle/util/Strings.java
@@ -13,42 +13,35 @@ import java.util.Vector;
*/
public final class Strings
{
- // BEGIN android-changed
- // Was: private static String LINE_SEPARATOR;
- // It was using the static block below to initialize, calling System.getProperty, which caused
- // BouncyCastleProvider not to be compile-time initializable, thus causing performance problems
- // (see b/28108158 ). Anyway, this is already hardcoded in System.java
- private static String LINE_SEPARATOR = "\n";
- // END android-changed
- // BEGIN android-removed
- // static
- // {
- // try
- // {
- // LINE_SEPARATOR = AccessController.doPrivileged(new PrivilegedAction<String>()
- // {
- // public String run()
- // {
- // // the easy way
- // return System.getProperty("line.separator");
- // }
- // });
-
- // }
- // catch (Exception e)
- // {
- // try
- // {
- // // the harder way
- // LINE_SEPARATOR = String.format("%n");
- // }
- // catch (Exception ef)
- // {
- // LINE_SEPARATOR = "\n"; // we're desperate use this...
- // }
- // }
- // }
- // END android-removed
+ private static String LINE_SEPARATOR;
+
+ static
+ {
+ try
+ {
+ LINE_SEPARATOR = AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ // the easy way
+ return System.getProperty("line.separator");
+ }
+ });
+
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ // the harder way
+ LINE_SEPARATOR = String.format("%n");
+ }
+ catch (Exception ef)
+ {
+ LINE_SEPARATOR = "\n"; // we're desperate use this...
+ }
+ }
+ }
public static String fromUTF8ByteArray(byte[] bytes)
{