Backed out changeset d38c3ad6fe5b (bug 1381984) for Android checkstyle bustage on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 19 Jul 2017 21:40:06 -0400
changeset 418490 02b3fd4876ff55b8e8a04e650ccd067bfcded748
parent 418489 50d28d418535c3921318ee430dc49eca3a7731b5
child 418491 b7ca046bede550b4ccbce70f1349578b5fb25756
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1381984
milestone56.0a1
backs outd38c3ad6fe5b2af851f7d5b033e9b60d9075ec6b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset d38c3ad6fe5b (bug 1381984) for Android checkstyle bustage on a CLOSED TREE.
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
@@ -271,9 +271,28 @@ public class StringUtils {
      */
     public static String forceLTR(String text) {
         if (!isRTL(text)) {
             return text;
         }
 
         return "\u200E" + text;
     }
+
+    /**
+     * Joining together a sequence of strings with a separator.
+     */
+    public static String join(@NonNull String separator, @NonNull List<String> parts) {
+        if (parts.size() == 0) {
+            return "";
+        }
+
+        final StringBuilder builder = new StringBuilder();
+        builder.append(parts.get(0));
+
+        for (int i = 1; i < parts.size(); i++) {
+            builder.append(separator);
+            builder.append(parts.get(i));
+        }
+
+        return builder.toString();
+    }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
@@ -54,17 +54,17 @@ public class PublicSuffix {
      */
     @WorkerThread
     private static int findPublicSuffixIndex(Context context, String domain) {
         final List<String> parts = normalizeAndSplit(domain);
         final int partsSize = parts.size();
         final Set<String> exact = PublicSuffixPatterns.getExactSet(context);
 
         for (int i = 0; i < partsSize; i++) {
-            String ancestorName = TextUtils.join(".", parts.subList(i, partsSize));
+            String ancestorName = StringUtils.join(".", parts.subList(i, partsSize));
 
             if (exact.contains(ancestorName)) {
                 return joinIndex(parts, i);
             }
 
             // Excluded domains (e.g. !nhs.uk) use the next highest
             // domain as the effective public suffix (e.g. uk).
             if (PublicSuffixPatterns.EXCLUDED.contains(ancestorName)) {
--- a/mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
@@ -99,16 +99,33 @@ public class TestStringUtils {
         assertEquals(4, someRtlString.length());
         final String forcedLtrString = StringUtils.forceLTR(someRtlString);
         assertEquals(5, forcedLtrString.length());
         final String forcedAgainLtrString = StringUtils.forceLTR(forcedLtrString);
         assertEquals(5, forcedAgainLtrString.length());
     }
 
     @Test
+    public void testJoin() {
+        assertEquals("", StringUtils.join("", Collections.<String>emptyList()));
+        assertEquals("", StringUtils.join("-", Collections.<String>emptyList()));
+        assertEquals("", StringUtils.join("", Collections.singletonList("")));
+        assertEquals("", StringUtils.join(".", Collections.singletonList("")));
+
+        assertEquals("192.168.0.1", StringUtils.join(".", Arrays.asList("192", "168", "0", "1")));
+        assertEquals("www.mozilla.org", StringUtils.join(".", Arrays.asList("www", "mozilla", "org")));
+
+        assertEquals("hello", StringUtils.join("", Collections.singletonList("hello")));
+        assertEquals("helloworld", StringUtils.join("", Arrays.asList("hello", "world")));
+        assertEquals("hello world", StringUtils.join(" ", Arrays.asList("hello", "world")));
+
+        assertEquals("m::o::z::i::l::l::a", StringUtils.join("::", Arrays.asList("m", "o", "z", "i", "l", "l", "a")));
+    }
+
+    @Test
     public void testIsSearchQuery(){
         boolean any = true;
         // test trim
         assertFalse(StringUtils.isSearchQuery("",false));
         assertTrue(StringUtils.isSearchQuery("",true));
 
         // test space
         assertTrue(StringUtils.isSearchQuery(" apple pen ",any));