You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2017/05/19 17:30:24 UTC
[1/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Repository: geode
Updated Branches:
refs/heads/develop 9af854aa4 -> d16d192b2
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
index 7bd7462..d3c1200 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
@@ -14,6 +14,12 @@
*/
package org.apache.geode.distributed;
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.then;
+
import org.apache.geode.distributed.ServerLauncher.Builder;
import org.apache.geode.distributed.ServerLauncher.Command;
import org.apache.geode.distributed.internal.DistributionConfig;
@@ -32,12 +38,6 @@ import java.io.FileWriter;
import java.net.InetAddress;
import java.util.Properties;
-import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.BDDAssertions.then;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
/**
* Integration tests for ServerLauncher class. These tests may require file system and/or network
* I/O.
@@ -157,7 +157,7 @@ public class ServerLauncherIntegrationTest {
gemfireProperties);
// when: starting with null MemberName
- ServerLauncher launcher = new Builder().setCommand(Command.START).setMemberName(null).build();
+ ServerLauncher launcher = new Builder().setCommand(Command.START).build();
// then: name in gemfire.properties file should be used for MemberName
assertThat(launcher).isNotNull();
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
index f5d6271..98f73d8 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
@@ -14,17 +14,24 @@
*/
package org.apache.geode.distributed;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.distributed.ServerLauncher.Builder;
import org.apache.geode.distributed.ServerLauncher.Command;
import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.distributed.support.DistributedSystemAdapter;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.test.junit.categories.FlakyTest;
import org.apache.geode.test.junit.categories.UnitTest;
-import edu.umd.cs.mtc.MultithreadedTestCase;
-import edu.umd.cs.mtc.TestFramework;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.concurrent.Synchroniser;
@@ -42,9 +49,8 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.junit.Assert.*;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import edu.umd.cs.mtc.MultithreadedTestCase;
+import edu.umd.cs.mtc.TestFramework;
/**
* The ServerLauncherTest class is a test suite of unit tests testing the contract, functionality
@@ -77,6 +83,7 @@ public class ServerLauncherTest {
setThreadingPolicy(new Synchroniser());
}
};
+ DistributedSystem.removeSystem(InternalDistributedSystem.getConnectedInstance());
}
@After
@@ -162,8 +169,6 @@ public class ServerLauncherTest {
assertNull(builder.getMemberName());
assertSame(builder, builder.setMemberName("serverOne"));
assertEquals("serverOne", builder.getMemberName());
- assertSame(builder, builder.setMemberName(null));
- assertNull(builder.getMemberName());
}
@Test(expected = IllegalArgumentException.class)
@@ -190,6 +195,18 @@ public class ServerLauncherTest {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testSetMemberNameToNullString() {
+ try {
+ new Builder().setMemberName(null);
+ } catch (IllegalArgumentException expected) {
+ assertEquals(
+ LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Server"),
+ expected.getMessage());
+ throw expected;
+ }
+ }
+
@Test
public void testSetAndGetPid() {
Builder builder = new Builder();
@@ -277,8 +294,6 @@ public class ServerLauncherTest {
assertNull(builder.getHostNameForClients());
assertSame(builder, builder.setHostNameForClients("Pegasus"));
assertEquals("Pegasus", builder.getHostNameForClients());
- assertSame(builder, builder.setHostNameForClients(null));
- assertNull(builder.getHostNameForClients());
}
@Test
@@ -498,8 +513,8 @@ public class ServerLauncherTest {
@Test
public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
- ServerLauncher launcher = new Builder().setCommand(ServerLauncher.Command.START)
- .setMemberName(null).set(NAME, "serverABC").build();
+ ServerLauncher launcher =
+ new Builder().setCommand(ServerLauncher.Command.START).set(NAME, "serverABC").build();
assertNotNull(launcher);
assertEquals(ServerLauncher.Command.START, launcher.getCommand());
@@ -511,8 +526,7 @@ public class ServerLauncherTest {
public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + NAME, "serverXYZ");
- ServerLauncher launcher =
- new Builder().setCommand(ServerLauncher.Command.START).setMemberName(null).build();
+ ServerLauncher launcher = new Builder().setCommand(ServerLauncher.Command.START).build();
assertNotNull(launcher);
assertEquals(ServerLauncher.Command.START, launcher.getCommand());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/internal/lang/ClassUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/lang/ClassUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/lang/ClassUtilsJUnitTest.java
index 3ec3b06..cc83faa 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/lang/ClassUtilsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/lang/ClassUtilsJUnitTest.java
@@ -14,15 +14,17 @@
*/
package org.apache.geode.internal.lang;
-import static org.junit.Assert.*;
-
-import java.util.Calendar;
-import java.util.Date;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.apache.geode.test.junit.categories.UnitTest;
+import java.util.Calendar;
+import java.util.Date;
/**
* The ClassUtilsJUnitTest class is a test suite with test cases to test the contract and
@@ -61,8 +63,7 @@ public class ClassUtilsJUnitTest {
@Test(expected = IllegalArgumentException.class)
public void testForNameWithEmptyClassName() {
try {
- ClassUtils.forName(StringUtils.EMPTY_STRING,
- new IllegalArgumentException("Empty Class Name!"));
+ ClassUtils.forName(StringUtils.EMPTY, new IllegalArgumentException("Empty Class Name!"));
} catch (IllegalArgumentException expected) {
assertEquals("Empty Class Name!", expected.getMessage());
throw expected;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/internal/lang/StringUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/lang/StringUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/lang/StringUtilsJUnitTest.java
index f3e0abe..503356a 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/lang/StringUtilsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/lang/StringUtilsJUnitTest.java
@@ -14,19 +14,20 @@
*/
package org.apache.geode.internal.lang;
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import org.apache.geode.DataSerializer;
import org.apache.geode.internal.cache.CachedDeserializable;
import org.apache.geode.internal.cache.CachedDeserializableFactory;
import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
/**
* The StringUtilsJUnitTest is a test suite containing test cases for testing the contract and
@@ -42,55 +43,7 @@ import org.apache.geode.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class StringUtilsJUnitTest {
- @Test
- public void testConcat() {
- assertEquals("", StringUtils.concat((Object[]) null));
- assertEquals("", StringUtils.concat(""));
- assertEquals(" ", StringUtils.concat(" "));
- assertEquals(" ", StringUtils.concat(" "));
- assertEquals("123", StringUtils.concat("123"));
- assertEquals("1 2 3", StringUtils.concat("1 2 3"));
- assertEquals(" 1 2 3 ", StringUtils.concat(" 1 2 3 "));
- assertEquals("trueC13.14159test", StringUtils.concat(true, 'C', 1, 3.14159f, "test"));
- assertEquals("test testing tested", StringUtils.concat("test", " testing", " tested"));
- }
- @Test
- public void testConcatWithDelimiter() {
- assertEquals("", StringUtils.concat(null, null));
- assertEquals("", StringUtils.concat(null, " "));
- assertEquals("", StringUtils.concat(new Object[] {""}, " "));
- assertEquals(" ", StringUtils.concat(new Object[] {" "}, " "));
- assertEquals(" ", StringUtils.concat(new Object[] {" ", " ", " "}, " "));
- assertEquals(" | | ", StringUtils.concat(new Object[] {" ", " ", " "}, "|"));
- assertEquals("abc", StringUtils.concat(new Object[] {"a", "b", "c"}, null));
- assertEquals("abc", StringUtils.concat(new Object[] {"a", "b", "c"}, ""));
- assertEquals("a b c", StringUtils.concat(new Object[] {"a", "b", "c"}, " "));
- assertEquals("a b c", StringUtils.concat(new Object[] {"a", "b", "c"}, " "));
- assertEquals("a_b_c", StringUtils.concat(new Object[] {"a", "b", "c"}, "_"));
- assertEquals("a|b|c", StringUtils.concat(new Object[] {"a", "b", "c"}, "|"));
- assertEquals("a>b>c", StringUtils.concat(new Object[] {"a", "b", "c"}, ">"));
- assertEquals("a&b&c", StringUtils.concat(new Object[] {"a", "b", "c"}, "&"));
- assertEquals("*", StringUtils.concat(new Object[] {"*"}, "*"));
- assertEquals("***", StringUtils.concat(new Object[] {"*", "*"}, "*"));
- assertEquals("*-*", StringUtils.concat(new Object[] {"*", "*"}, "-"));
- }
-
- @Test
- public void testDefaultIfBlank() {
- assertNull(StringUtils.defaultIfBlank((String[]) null));
- assertNull(null, StringUtils.defaultIfBlank(null, ""));
- assertNull(null, StringUtils.defaultIfBlank(null, "", " "));
- assertNull(null, StringUtils.defaultIfBlank(null, "", " ", "\0"));
- assertEquals("test", StringUtils.defaultIfBlank("test", null, "", " "));
- assertEquals("test", StringUtils.defaultIfBlank(null, "", " ", "test"));
- assertEquals("test", StringUtils.defaultIfBlank(null, "", "test", " ", null));
- assertEquals("_", StringUtils.defaultIfBlank("_", null, "", " "));
- assertEquals("empty", StringUtils.defaultIfBlank(null, "", "empty", " "));
- assertEquals("blank", StringUtils.defaultIfBlank(null, "", " ", "blank"));
- assertEquals("null", StringUtils.defaultIfBlank("null", null, "", " "));
- assertEquals("null", StringUtils.defaultIfBlank("null", "empty", "blank"));
- }
@Test
public void testGetDigitsOnly() {
@@ -107,186 +60,7 @@ public class StringUtilsJUnitTest {
assertEquals("123456789", StringUtils.getDigitsOnly("123,456.789"));
}
- @Test
- public void testGetLettersOnly() {
- assertEquals("", StringUtils.getLettersOnly(null));
- assertEquals("", StringUtils.getLettersOnly(""));
- assertEquals("", StringUtils.getLettersOnly(" "));
- assertEquals("", StringUtils.getLettersOnly("123"));
- assertEquals("", StringUtils.getLettersOnly("123@$$!"));
- assertEquals("", StringUtils.getLettersOnly("!@$$%#*?"));
- assertEquals("", StringUtils.getLettersOnly("10101"));
- assertEquals("lll", StringUtils.getLettersOnly("l0l0l"));
- assertEquals("", StringUtils.getLettersOnly("007"));
- assertEquals("OO", StringUtils.getLettersOnly("OO7"));
- assertEquals("OOSeven", StringUtils.getLettersOnly("OOSeven"));
- }
-
- @Test
- public void testGetSpaces() {
- assertEquals("", StringUtils.getSpaces(0));
- assertEquals(" ", StringUtils.getSpaces(1));
- assertEquals(" ", StringUtils.getSpaces(2));
- assertEquals(" ", StringUtils.getSpaces(3));
- assertEquals(" ", StringUtils.getSpaces(4));
- assertEquals(" ", StringUtils.getSpaces(5));
- assertEquals(" ", StringUtils.getSpaces(6));
- assertEquals(" ", StringUtils.getSpaces(7));
- assertEquals(" ", StringUtils.getSpaces(8));
- assertEquals(" ", StringUtils.getSpaces(9));
- assertEquals(" ", StringUtils.getSpaces(10));
- assertEquals(" ", StringUtils.getSpaces(11));
- assertEquals(" ", StringUtils.getSpaces(12));
- assertEquals(" ", StringUtils.getSpaces(13));
- assertEquals(" ", StringUtils.getSpaces(14));
- assertEquals(" ", StringUtils.getSpaces(15));
- assertEquals(" ", StringUtils.getSpaces(16));
- assertEquals(" ", StringUtils.getSpaces(17));
- assertEquals(" ", StringUtils.getSpaces(18));
- assertEquals(" ", StringUtils.getSpaces(19));
- assertEquals(" ", StringUtils.getSpaces(20));
- assertEquals(" ", StringUtils.getSpaces(21));
- }
-
- @Test
- public void testIsBlank() {
- assertTrue(StringUtils.isBlank(null));
- assertTrue(StringUtils.isBlank(""));
- assertTrue(StringUtils.isBlank("\0"));
- assertTrue(StringUtils.isBlank(" "));
- assertTrue(StringUtils.isBlank(" "));
- }
-
- @Test
- public void testIsNotBlank() {
- assertFalse(StringUtils.isBlank("test"));
- assertFalse(StringUtils.isBlank("null"));
- assertFalse(StringUtils.isBlank("empty"));
- assertFalse(StringUtils.isBlank("_"));
- assertFalse(StringUtils.isBlank("____"));
- }
-
- @Test
- public void testIsEmpty() {
- assertTrue(StringUtils.isEmpty(""));
- }
-
- @Test
- public void testIsNotEmpty() {
- assertFalse(StringUtils.isEmpty("test"));
- assertFalse(StringUtils.isEmpty("null"));
- assertFalse(StringUtils.isEmpty("empty"));
- assertFalse(StringUtils.isEmpty(null));
- assertFalse(StringUtils.isEmpty(" "));
- assertFalse(StringUtils.isEmpty(" "));
- assertFalse(StringUtils.isEmpty("_"));
- assertFalse(StringUtils.isEmpty("___"));
- }
- @Test
- public void testPadEnding() {
- assertEquals("", StringUtils.padEnding("", 'X', 0));
- assertEquals(" ", StringUtils.padEnding(" ", 'X', 0));
- assertEquals(" ", StringUtils.padEnding(" ", 'X', 1));
- assertEquals(" ", StringUtils.padEnding(" ", 'X', 0));
- assertEquals(" ", StringUtils.padEnding(" ", 'X', 3));
- assertEquals("X", StringUtils.padEnding("", 'X', 1));
- assertEquals(" X", StringUtils.padEnding(" ", 'X', 2));
- assertEquals(" XX", StringUtils.padEnding(" ", 'X', 4));
- assertEquals("test", StringUtils.padEnding("test", 'X', 0));
- assertEquals("test", StringUtils.padEnding("test", 'X', 4));
- assertEquals("testX", StringUtils.padEnding("test", 'X', 5));
- assertEquals("testXXX", StringUtils.padEnding("test", 'X', 7));
- }
-
- @Test(expected = NullPointerException.class)
- public void testPadEndingWithNull() {
- try {
- StringUtils.padEnding(null, 'X', 10);
- } catch (NullPointerException expected) {
- assertEquals("The String value to pad cannot be null!", expected.getMessage());
- throw expected;
- }
- }
-
- @Test
- public void testToLowerCase() {
- assertNull(StringUtils.toLowerCase(null));
- assertEquals("null", StringUtils.toLowerCase("null"));
- assertEquals("null", StringUtils.toLowerCase("NULL"));
- assertEquals("", StringUtils.toLowerCase(""));
- assertEquals(" ", StringUtils.toLowerCase(" "));
- assertEquals("test", StringUtils.toLowerCase("TEST"));
- assertEquals("1", StringUtils.toLowerCase("1"));
- assertEquals("!", StringUtils.toLowerCase("!"));
- assertEquals("$00", StringUtils.toLowerCase("$00"));
- assertEquals("jon doe", StringUtils.toLowerCase("Jon Doe"));
- }
-
- @Test
- public void testToUpperCase() {
- assertNull(StringUtils.toUpperCase(null));
- assertEquals("NULL", StringUtils.toUpperCase("NULL"));
- assertEquals("NULL", StringUtils.toUpperCase("null"));
- assertEquals("", StringUtils.toUpperCase(""));
- assertEquals(" ", StringUtils.toUpperCase(" "));
- assertEquals("TEST", StringUtils.toUpperCase("test"));
- assertEquals("2", StringUtils.toUpperCase("2"));
- assertEquals("!", StringUtils.toUpperCase("!"));
- assertEquals("$00", StringUtils.toUpperCase("$00"));
- assertEquals("JON DOE", StringUtils.toUpperCase("Jon Doe"));
- }
-
- @Test
- public void testTrim() {
- assertNull(StringUtils.trim(null));
- assertEquals("", StringUtils.trim(""));
- assertEquals("", StringUtils.trim(" "));
- assertEquals("", StringUtils.trim(" "));
- assertEquals("null", StringUtils.trim("null"));
- assertEquals("test", StringUtils.trim(" test"));
- assertEquals("test", StringUtils.trim("test "));
- assertEquals("test", StringUtils.trim(" test "));
- assertEquals("a b c d", StringUtils.trim(" a b c d "));
- }
-
- @Test
- public void testTruncate() {
- assertEquals("", StringUtils.truncate("", 0));
- assertEquals("", StringUtils.truncate("", 1));
- assertEquals(" ", StringUtils.truncate(" ", 1));
- assertEquals(" ", StringUtils.truncate(" ", 5));
- assertEquals(" ", StringUtils.truncate(" ", 1));
- assertEquals("XX", StringUtils.truncate("XXX", 2));
- assertEquals("XX", StringUtils.truncate("XX", 4));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testTruncateWithNegativeLength() {
- try {
- StringUtils.truncate("XX", -1);
- } catch (IllegalArgumentException expected) {
- assertEquals("Length must be greater than equal to 0!", expected.getMessage());
- throw expected;
- }
- }
-
- @Test
- public void testValueOf() {
- assertEquals("null", StringUtils.valueOf(null));
- assertEquals("null", StringUtils.valueOf(null, (String[]) null));
- assertEquals("null", StringUtils.valueOf(null, new String[] {}));
- assertEquals("test", StringUtils.valueOf(null, "test"));
- assertEquals("nil", StringUtils.valueOf(null, "nil", "test"));
- assertEquals("test", StringUtils.valueOf("test", (String[]) null));
- assertEquals("null", StringUtils.valueOf("null", "test"));
- assertEquals("nil", StringUtils.valueOf("nil", "mock", "test"));
- assertEquals("", StringUtils.valueOf("", "test", "mock", "null"));
- assertEquals(" ", StringUtils.valueOf(" ", "test", "mock", "nil"));
- assertEquals("true", StringUtils.valueOf(true, "test", "nil", null));
- assertEquals("1", StringUtils.valueOf(1, "one"));
- assertEquals(String.valueOf(Math.PI), StringUtils.valueOf(Math.PI, "314159"));
- }
@Test
public void testWrap() {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/internal/util/CollectionUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/util/CollectionUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/util/CollectionUtilsJUnitTest.java
index 36be8b8..c760597 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/util/CollectionUtilsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/util/CollectionUtilsJUnitTest.java
@@ -14,7 +14,19 @@
*/
package org.apache.geode.internal.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,18 +38,11 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Vector;
import java.util.Map.Entry;
+import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
-
-import org.apache.geode.internal.lang.Filter;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import java.util.Vector;
/**
* The CollectionUtilsJUnitTest class is a test suite of test cases testing the contract and
@@ -105,7 +110,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testCreateMultipleProperties() {
- Map<String, String> map = new HashMap<String, String>(3);
+ Map<String, String> map = new HashMap<>(3);
map.put("one", "A");
map.put("two", "B");
@@ -141,7 +146,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testEmptyListWithEmptyList() {
- final List<Object> expectedList = new ArrayList<Object>(0);
+ final List<Object> expectedList = new ArrayList<>(0);
assertNotNull(expectedList);
assertTrue(expectedList.isEmpty());
@@ -174,7 +179,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testEmptySetWithEmptySet() {
- final Set<Object> expectedSet = new HashSet<Object>(0);
+ final Set<Object> expectedSet = new HashSet<>(0);
assertNotNull(expectedSet);
assertTrue(expectedSet.isEmpty());
@@ -187,7 +192,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testEmptySetWithSet() {
final Set<String> expectedSet =
- new HashSet<String>(Arrays.asList("aardvark", "baboon", "cat", "dog", "ferret"));
+ new HashSet<>(Arrays.asList("aardvark", "baboon", "cat", "dog", "ferret"));
assertNotNull(expectedSet);
assertFalse(expectedSet.isEmpty());
@@ -201,12 +206,8 @@ public class CollectionUtilsJUnitTest {
public void testFindAll() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9);
- final List<Integer> matches = CollectionUtils.findAll(numbers, new Filter<Integer>() {
- // accept all even numbers
- public boolean accept(final Integer number) {
- return (number % 2 == 0);
- }
- });
+ // accept all even numbers
+ final List<Integer> matches = CollectionUtils.findAll(numbers, number -> (number % 2 == 0));
assertNotNull(matches);
assertFalse(matches.isEmpty());
@@ -217,12 +218,8 @@ public class CollectionUtilsJUnitTest {
public void testFindAllWhenMultipleElementsMatch() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 1, 4, 1, 6, 1, 7, 1, 9);
- final List<Integer> matches = CollectionUtils.findAll(numbers, new Filter<Integer>() {
- // accept 1
- public boolean accept(final Integer number) {
- return (number == 1);
- }
- });
+ // accept 1
+ final List<Integer> matches = CollectionUtils.findAll(numbers, number -> (number == 1));
assertNotNull(matches);
assertEquals(5, matches.size());
@@ -233,12 +230,8 @@ public class CollectionUtilsJUnitTest {
public void testFindAllWhenNoElementsMatch() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- final List<Integer> matches = CollectionUtils.findAll(numbers, new Filter<Integer>() {
- // accept negative numbers
- public boolean accept(final Integer number) {
- return (number < 0);
- }
- });
+ // accept negative numbers
+ final List<Integer> matches = CollectionUtils.findAll(numbers, number -> (number < 0));
assertNotNull(matches);
assertTrue(matches.isEmpty());
@@ -248,12 +241,8 @@ public class CollectionUtilsJUnitTest {
public void testFindBy() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9);
- final Integer match = CollectionUtils.findBy(numbers, new Filter<Integer>() {
- // accept 2
- public boolean accept(final Integer number) {
- return (number == 2);
- }
- });
+ // accept 2
+ final Integer match = CollectionUtils.findBy(numbers, number -> (number == 2));
assertNotNull(match);
assertEquals(2, match.intValue());
@@ -263,12 +252,8 @@ public class CollectionUtilsJUnitTest {
public void testFindByWhenMultipleElementsMatch() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 1, 4, 1, 6, 1, 7, 1, 9);
- final Integer match = CollectionUtils.findBy(numbers, new Filter<Integer>() {
- // accept 1
- public boolean accept(final Integer number) {
- return (number == 1);
- }
- });
+ // accept 1
+ final Integer match = CollectionUtils.findBy(numbers, number -> (number == 1));
assertNotNull(match);
assertEquals(1, match.intValue());
@@ -278,19 +263,15 @@ public class CollectionUtilsJUnitTest {
public void testFindByWhenNoElementsMatch() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9);
- final Integer match = CollectionUtils.findBy(numbers, new Filter<Integer>() {
- // accept 10
- public boolean accept(final Integer number) {
- return (number == 10);
- }
- });
+ // accept 10
+ final Integer match = CollectionUtils.findBy(numbers, number -> (number == 10));
assertNull(match);
}
@Test
public void testRemoveKeys() {
- final Map<Object, String> expectedMap = new HashMap<Object, String>(6);
+ final Map<Object, String> expectedMap = new HashMap<>(6);
expectedMap.put("key1", "value");
expectedMap.put("key2", "null");
@@ -303,12 +284,7 @@ public class CollectionUtilsJUnitTest {
assertEquals(6, expectedMap.size());
final Map<Object, String> actualMap =
- CollectionUtils.removeKeys(expectedMap, new Filter<Map.Entry<Object, String>>() {
- @Override
- public boolean accept(final Map.Entry<Object, String> entry) {
- return !StringUtils.isBlank(entry.getValue());
- }
- });
+ CollectionUtils.removeKeys(expectedMap, entry -> StringUtils.isNotBlank(entry.getValue()));
assertSame(expectedMap, actualMap);
assertFalse(actualMap.isEmpty());
@@ -318,7 +294,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testRemoveKeysWithNullValues() {
- final Map<Object, Object> expectedMap = new HashMap<Object, Object>(3);
+ final Map<Object, Object> expectedMap = new HashMap<>(3);
expectedMap.put("one", "test");
expectedMap.put("two", null);
@@ -350,7 +326,7 @@ public class CollectionUtilsJUnitTest {
@Test
public void testRemoveKeysWithNullValuesFromMapWithNoNullValues() {
- final Map<String, Object> map = new HashMap<String, Object>(5);
+ final Map<String, Object> map = new HashMap<>(5);
map.put("one", "test");
map.put("null", "null");
@@ -430,7 +406,7 @@ public class CollectionUtilsJUnitTest {
list.add("one");
list.add("two");
- boolean modified = CollectionUtils.addAll(list, (Enumeration<String>) null);
+ boolean modified = CollectionUtils.addAll(list, null);
assertTrue(!modified);
assertEquals(2, list.size());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
index 91a59f8..7fedb9f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
@@ -14,21 +14,12 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.junit.Assert.*;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Collections;
-import java.util.Set;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.concurrent.Synchroniser;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import org.apache.geode.cache.execute.Function;
import org.apache.geode.cache.execute.FunctionService;
@@ -41,6 +32,19 @@ import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
import org.apache.geode.test.junit.categories.UnitTest;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.concurrent.Synchroniser;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.Set;
/**
* The AbstractCommandsSupportJUnitTest class is a test suite of test cases testing the contract and
@@ -140,9 +144,9 @@ public class AbstractCommandsSupportJUnitTest {
@Test
public void testConvertDefaultValue() {
- assertNull(AbstractCommandsSupport.convertDefaultValue(null, StringUtils.EMPTY_STRING));
- assertEquals(StringUtils.EMPTY_STRING,
- AbstractCommandsSupport.convertDefaultValue(StringUtils.EMPTY_STRING, "test"));
+ assertNull(AbstractCommandsSupport.convertDefaultValue(null, StringUtils.EMPTY));
+ assertEquals(StringUtils.EMPTY,
+ AbstractCommandsSupport.convertDefaultValue(StringUtils.EMPTY, "test"));
assertEquals(StringUtils.SPACE,
AbstractCommandsSupport.convertDefaultValue(StringUtils.SPACE, "testing"));
assertEquals("tested", AbstractCommandsSupport
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
index 8bf1c43..5ff0a67 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
@@ -14,14 +14,27 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import org.apache.geode.cache.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.assertSame;
+import static org.apache.geode.test.dunit.Assert.assertTrue;
+import static org.apache.geode.test.dunit.LogWriterUtils.getDUnitLogLevel;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.Scope;
import org.apache.geode.cache.query.Index;
import org.apache.geode.cache.query.IndexStatistics;
import org.apache.geode.cache.query.IndexType;
import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.internal.lang.MutableIdentifiable;
import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.cli.domain.IndexDetails;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -34,15 +47,17 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.LogWriterUtils.getDUnitLogLevel;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
/**
* The ListIndexCommandDUnitTest class is distributed test suite of test cases for testing the
* index-based GemFire shell (Gfsh) commands.
@@ -57,7 +72,7 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
private static final int DEFAULT_REGION_INITIAL_CAPACITY = 10000;
- private final AtomicLong idGenerator = new AtomicLong(0l);
+ private final AtomicLong idGenerator = new AtomicLong(0L);
@Override
public final void postSetUpCliCommandTestBase() throws Exception {
@@ -186,7 +201,7 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
final Random random = new Random(System.currentTimeMillis());
int count = 0;
- final List<Proxy> proxies = new ArrayList<Proxy>();
+ final List<Proxy> proxies = new ArrayList<>();
Consumer consumer;
Proxy proxy;
@@ -232,7 +247,7 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
final Random random = new Random(System.currentTimeMillis());
int count = 0;
- final List<Proxy> proxies = new ArrayList<Proxy>();
+ final List<Proxy> proxies = new ArrayList<>();
Producer producer;
Proxy proxy;
@@ -322,7 +337,7 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
private final Properties distributedSystemProperties;
- private final Set<RegionDefinition> regions = new HashSet<RegionDefinition>();
+ private final Set<RegionDefinition> regions = new HashSet<>();
private final VM vm;
@@ -471,14 +486,14 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
private final Class<?> keyConstraint;
private final Class<?> valueConstraint;
- private final Set<Index> indexes = new HashSet<Index>();
+ private final Set<Index> indexes = new HashSet<>();
private final String regionName;
@SuppressWarnings("unchecked")
protected RegionDefinition(final String regionName, final Class<?> keyConstraint,
final Class<?> valueConstraint) {
- assert !StringUtils.isBlank(regionName) : "The name of the Region must be specified!";
+ assert StringUtils.isNotBlank(regionName) : "The name of the Region must be specified!";
this.regionName = regionName;
this.keyConstraint = ObjectUtils.defaultIfNull(keyConstraint, Object.class);
this.valueConstraint = ObjectUtils.defaultIfNull(valueConstraint, Object.class);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
index fc920c4..cea77fa 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
@@ -21,14 +21,13 @@ import static java.util.stream.Collectors.toSet;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.distributed.internal.ClusterConfigurationService;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.DeployedJar;
-import org.apache.geode.internal.JarDeployer;
import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.configuration.domain.Configuration;
import org.apache.geode.test.dunit.rules.Locator;
import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
@@ -41,7 +40,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -93,7 +91,7 @@ public class ClusterConfig implements Serializable {
Set<String> expectedGroupConfigs =
this.getGroups().stream().map(ConfigGroup::getName).collect(toSet());
- // verify info exists in memeory
+ // verify info exists in memory
locatorVM.invoke(() -> {
InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
@@ -107,8 +105,8 @@ public class ClusterConfig implements Serializable {
Configuration config = sc.getConfiguration(configGroup.name);
assertThat(config.getJarNames()).isEqualTo(configGroup.getJars());
- // verify proeprty is as expected
- if (!StringUtils.isBlank(configGroup.getMaxLogFileSize())) {
+ // verify property is as expected
+ if (StringUtils.isNotBlank(configGroup.getMaxLogFileSize())) {
Properties props = config.getGemfireProperties();
assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT))
.isEqualTo(configGroup.getMaxLogFileSize());
@@ -135,7 +133,7 @@ public class ClusterConfig implements Serializable {
}
}
- public void verifyServer(MemberVM<Server> serverVM) throws ClassNotFoundException {
+ public void verifyServer(MemberVM<Server> serverVM) {
// verify files exist in filesystem
Set<String> expectedJarNames = this.getJarNames().stream().collect(toSet());
@@ -156,7 +154,7 @@ public class ClusterConfig implements Serializable {
assertThat(cache.getRegion(region)).isNotNull();
}
- if (!StringUtils.isBlank(this.getMaxLogFileSize())) {
+ if (StringUtils.isNotBlank(this.getMaxLogFileSize())) {
Properties props = cache.getDistributedSystem().getProperties();
assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT)).isEqualTo(this.getMaxLogFileSize());
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index 19a1662..bc709db 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -17,7 +17,7 @@ package org.apache.geode.test.dunit.rules;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
import static org.assertj.core.api.Assertions.assertThat;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.cli.HeadlessGfsh;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index b2be12a..033fedc 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.cache.lucene.internal.cli;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.SystemFailure;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.Execution;
@@ -28,7 +29,6 @@ import org.apache.geode.cache.lucene.internal.cli.functions.LuceneSearchIndexFun
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.execute.AbstractExecution;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.security.IntegratedSecurityService;
import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.management.cli.CliMetaData;
@@ -82,11 +82,10 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliCommand(value = LuceneCliStrings.LUCENE_LIST_INDEX,
help = LuceneCliStrings.LUCENE_LIST_INDEX__HELP)
- @CliMetaData(shellOnly = false,
- relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result listIndex(@CliOption(key = LuceneCliStrings.LUCENE_LIST_INDEX__STATS,
- mandatory = false, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
+ specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
help = LuceneCliStrings.LUCENE_LIST_INDEX__STATS__HELP) final boolean stats) {
try {
@@ -120,7 +119,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
List<LuceneIndexDetails> sortedResults =
results.stream().flatMap(set -> set.stream()).sorted().collect(Collectors.toList());
- LinkedHashSet<LuceneIndexDetails> uniqResults = new LinkedHashSet<LuceneIndexDetails>();
+ LinkedHashSet<LuceneIndexDetails> uniqResults = new LinkedHashSet<>();
uniqResults.addAll(sortedResults);
sortedResults.clear();
sortedResults.addAll(uniqResults);
@@ -137,10 +136,9 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
indexData.accumulate("Server Name", indexDetails.getServerName());
indexData.accumulate("Indexed Fields", indexDetails.getSearchableFieldNamesString());
indexData.accumulate("Field Analyzer", indexDetails.getFieldAnalyzersString());
- indexData.accumulate("Status",
- indexDetails.getInitialized() == true ? "Initialized" : "Defined");
+ indexData.accumulate("Status", indexDetails.getInitialized() ? "Initialized" : "Defined");
- if (stats == true) {
+ if (stats) {
if (!indexDetails.getInitialized()) {
indexData.accumulate("Query Executions", "NA");
indexData.accumulate("Updates", "NA");
@@ -164,8 +162,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliCommand(value = LuceneCliStrings.LUCENE_CREATE_INDEX,
help = LuceneCliStrings.LUCENE_CREATE_INDEX__HELP)
- @CliMetaData(shellOnly = false,
- relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
// TODO : Add optionContext for indexName
public Result createIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
help = LuceneCliStrings.LUCENE_CREATE_INDEX__NAME__HELP) final String indexName,
@@ -177,11 +174,10 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliOption(key = LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, mandatory = true,
help = LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD_HELP) final String[] fields,
- @CliOption(key = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, mandatory = false,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+ @CliOption(key = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER,
help = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER_HELP) final String[] analyzers) {
- Result result = null;
+ Result result;
XmlEntity xmlEntity = null;
this.securityService.authorizeRegionManage(regionPath);
@@ -222,8 +218,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliCommand(value = LuceneCliStrings.LUCENE_DESCRIBE_INDEX,
help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__HELP)
- @CliMetaData(shellOnly = false,
- relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result describeIndex(
@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
@@ -262,8 +257,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliCommand(value = LuceneCliStrings.LUCENE_SEARCH_INDEX,
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__HELP)
- @CliMetaData(shellOnly = false,
- relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@ResourceOperation(resource = Resource.DATA, operation = Operation.WRITE)
public Result searchIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__NAME__HELP) final String indexName,
@@ -278,15 +272,14 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, mandatory = true,
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD__HELP) final String defaultField,
- @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT, mandatory = false,
- unspecifiedDefaultValue = "-1",
+ @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT, unspecifiedDefaultValue = "-1",
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT__HELP) final int limit,
- @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__PAGE_SIZE, mandatory = false,
+ @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__PAGE_SIZE,
unspecifiedDefaultValue = "-1",
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__PAGE_SIZE__HELP) int pageSize,
- @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY, mandatory = false,
+ @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY,
unspecifiedDefaultValue = "false",
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY__HELP) boolean keysOnly) {
try {
@@ -315,11 +308,9 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliCommand(value = LuceneCliStrings.LUCENE_DESTROY_INDEX,
help = LuceneCliStrings.LUCENE_DESTROY_INDEX__HELP)
- @CliMetaData(shellOnly = false,
- relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
- public Result destroyIndex(
- @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = false,
- help = LuceneCliStrings.LUCENE_DESTROY_INDEX__NAME__HELP) final String indexName,
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+ public Result destroyIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME,
+ help = LuceneCliStrings.LUCENE_DESTROY_INDEX__NAME__HELP) final String indexName,
@CliOption(key = LuceneCliStrings.LUCENE__REGION_PATH, mandatory = true,
optionContext = ConverterHint.REGION_PATH,
@@ -329,7 +320,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__REGION_CANNOT_BE_EMPTY));
}
- if (StringUtils.isEmpty(indexName)) {
+ if (indexName != null && StringUtils.isEmpty(indexName)) {
return ResultBuilder.createInfoResult(
CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
index f7edd8f..a5ec7d5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
@@ -15,6 +15,7 @@
package org.apache.geode.cache.lucene.internal.cli.functions;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.execute.FunctionAdapter;
@@ -26,12 +27,10 @@ import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
import org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails;
import org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo;
import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index d4dca4a..143e99d 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -14,32 +14,18 @@
*/
package org.apache.geode.cache.lucene.internal.cli;
-import static org.junit.Assert.*;
+import static junit.framework.TestCase.assertSame;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.core.KeywordAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import org.apache.geode.cache.execute.Execution;
import org.apache.geode.cache.execute.ResultCollector;
@@ -60,6 +46,25 @@ import org.apache.geode.management.internal.cli.result.ResultBuilder;
import org.apache.geode.management.internal.cli.result.TabularResultData;
import org.apache.geode.management.internal.cli.shell.Gfsh;
import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
/**
* The LuceneIndexCommandsJUnitTest class is a test suite of test cases testing the contract and
@@ -409,7 +414,7 @@ public class LuceneIndexCommandsJUnitTest {
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
- String expectedStatus = null;
+ String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(
LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1,
@@ -446,7 +451,7 @@ public class LuceneIndexCommandsJUnitTest {
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
- String expectedStatus = null;
+ String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(
LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1,
@@ -478,7 +483,7 @@ public class LuceneIndexCommandsJUnitTest {
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
- String expectedStatus = null;
+ String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(
LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0,
@@ -515,7 +520,7 @@ public class LuceneIndexCommandsJUnitTest {
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
- String expectedStatus = null;
+ String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(
LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0,
@@ -564,8 +569,8 @@ public class LuceneIndexCommandsJUnitTest {
}
// Verify each status
List<String> status = data.retrieveAllValues("Status");
- for (int i = 0; i < status.size(); i++) {
- assertEquals(expectedStatus, status.get(i));
+ for (String statu : status) {
+ assertEquals(expectedStatus, statu);
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
index 6ee5b53..7ce9c46 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
@@ -34,7 +34,6 @@ import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -57,7 +56,7 @@ public class PropMockDataUpdater implements IClusterUpdater {
private Cluster cluster = null;
private TestBed testbed;
- private final String testbedFile = System.getProperty("pulse.propMockDataUpdaterFile");;
+ private final String testbedFile = System.getProperty("pulse.propMockDataUpdaterFile");
private final ObjectMapper mapper = new ObjectMapper();
@@ -65,14 +64,12 @@ public class PropMockDataUpdater implements IClusterUpdater {
this.cluster = cluster;
try {
loadPropertiesFile();
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- private void loadPropertiesFile() throws FileNotFoundException, IOException {
+ private void loadPropertiesFile() throws IOException {
this.testbed = new TestBed(testbedFile, true);
}
@@ -161,8 +158,8 @@ public class PropMockDataUpdater implements IClusterUpdater {
}
for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
- HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
- HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
+ HashMap<String, Cluster.Region> memberRegions = new HashMap<>();
+ HashMap<String, Cluster.Client> memberClientsHM = new HashMap<>();
Random randomGenerator = new Random();
@@ -277,10 +274,6 @@ public class PropMockDataUpdater implements IClusterUpdater {
memberRegion.setWanEnabled(false);
}
memberRegion.setWanEnabled(true);
- /*
- * memberRegion.setSystemRegionEntryCount(Long.valueOf(String.valueOf(Math
- * .abs(randomGenerator.nextInt(100)))));
- */
memberRegion.getMemberName().add(memName);
memberRegion.setMemberCount(memberCount);
return memberRegion;
@@ -369,7 +362,7 @@ public class PropMockDataUpdater implements IClusterUpdater {
if (memberArrList != null) {
memberArrList.add(m);
} else {
- ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
+ ArrayList<Cluster.Member> memberList = new ArrayList<>();
memberList.add(m);
physicalToMember.put(m.getHost(), memberList);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-spark-connector/geode-functions/src/main/java/org/apache/geode/spark/connector/internal/geodefunctions/RetrieveRegionFunction.java
----------------------------------------------------------------------
diff --git a/geode-spark-connector/geode-functions/src/main/java/org/apache/geode/spark/connector/internal/geodefunctions/RetrieveRegionFunction.java b/geode-spark-connector/geode-functions/src/main/java/org/apache/geode/spark/connector/internal/geodefunctions/RetrieveRegionFunction.java
index 096e4d5..7407cc8 100644
--- a/geode-spark-connector/geode-functions/src/main/java/org/apache/geode/spark/connector/internal/geodefunctions/RetrieveRegionFunction.java
+++ b/geode-spark-connector/geode-functions/src/main/java/org/apache/geode/spark/connector/internal/geodefunctions/RetrieveRegionFunction.java
@@ -16,25 +16,24 @@
*/
package org.apache.geode.spark.connector.internal.geodefunctions;
-import java.util.Iterator;
-import org.apache.logging.log4j.Logger;
-
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.partition.PartitionRegionHelper;
import org.apache.geode.cache.query.Query;
import org.apache.geode.cache.query.QueryService;
import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.cache.query.Struct;
-import org.apache.geode.internal.cache.*;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.partition.PartitionRegionHelper;
import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
import org.apache.geode.internal.cache.execute.InternalResultSender;
import org.apache.geode.internal.cache.partitioned.PREntriesIterator;
import org.apache.geode.internal.logging.LogService;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Iterator;
/**
* GemFire function that is used by `SparkContext.geodeRegion(regionPath, whereClause)`
@@ -85,10 +84,11 @@ public class RetrieveRegionFunction implements Function {
InternalRegionFunctionContext irfc = (InternalRegionFunctionContext) context;
LocalRegion localRegion = (LocalRegion) irfc.getDataSet();
boolean partitioned = localRegion.getDataPolicy().withPartitioning();
- if (where.trim().isEmpty())
+ if (StringUtils.isBlank(where)) {
retrieveFullRegion(irfc, partitioned, taskDesc);
- else
+ } else {
retrieveRegionWithWhereClause(irfc, localRegion, partitioned, where, taskDesc);
+ }
}
/** ------------------------------------------ */
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-web/src/test/java/org/apache/geode/management/internal/web/AbstractWebTestCase.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/AbstractWebTestCase.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/AbstractWebTestCase.java
index eac0b8d..73be12a 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/AbstractWebTestCase.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/AbstractWebTestCase.java
@@ -14,6 +14,9 @@
*/
package org.apache.geode.management.internal.web;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.management.internal.web.domain.Link;
+
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -22,9 +25,6 @@ import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.management.internal.web.domain.Link;
-
/**
* The AbstractWebDomainTests class is abstract base class containing functionality common to a test
* suite classes in the org.apache.geode.management.internal.web.domain package.
@@ -48,7 +48,7 @@ public abstract class AbstractWebTestCase {
assert values != null : "The Values for the Map cannot be null!";
assert keys.length == values.length;
- final Map<K, V> map = new HashMap<K, V>(keys.length);
+ final Map<K, V> map = new HashMap<>(keys.length);
int index = 0;
for (final K key : keys) {
@@ -59,11 +59,11 @@ public abstract class AbstractWebTestCase {
}
protected String decode(final String encodedValue) throws UnsupportedEncodingException {
- return URLDecoder.decode(encodedValue, StringUtils.UTF_8);
+ return URLDecoder.decode(encodedValue, "UTF-8");
}
protected String encode(final String value) throws UnsupportedEncodingException {
- return URLEncoder.encode(value, StringUtils.UTF_8);
+ return URLEncoder.encode(value, "UTF-8");
}
protected String toString(final Link... links) throws UnsupportedEncodingException {
@@ -71,7 +71,7 @@ public abstract class AbstractWebTestCase {
int count = 0;
for (final Link link : links) {
- buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY_STRING).append(toString(link));
+ buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY).append(toString(link));
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/ShellCommandsControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/ShellCommandsControllerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/ShellCommandsControllerJUnitTest.java
index 37ec508..10e26f6 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/ShellCommandsControllerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/ShellCommandsControllerJUnitTest.java
@@ -14,17 +14,18 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.servlet.http.HttpServletRequest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.internal.cli.util.ClasspathScanLoadHelper;
+import org.apache.geode.management.internal.web.domain.Link;
+import org.apache.geode.management.internal.web.domain.LinkIndex;
+import org.apache.geode.management.internal.web.util.UriUtils;
+import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,12 +38,14 @@ import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import org.apache.geode.management.cli.CliMetaData;
-import org.apache.geode.management.internal.cli.util.ClasspathScanLoadHelper;
-import org.apache.geode.management.internal.web.domain.Link;
-import org.apache.geode.management.internal.web.domain.LinkIndex;
-import org.apache.geode.management.internal.web.util.UriUtils;
-import org.apache.geode.test.junit.categories.UnitTest;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
/**
* The ShellCommandsControllerJUnitTest class is a test suite of test cases testing the contract and
@@ -123,8 +126,7 @@ public class ShellCommandsControllerJUnitTest {
String[] requestParameters = requestMappingAnnotation.params();
if (requestParameters.length > 0) {
- webServiceEndpoint += "?".concat(
- org.apache.geode.internal.lang.StringUtils.concat(requestParameters, "&"));
+ webServiceEndpoint += "?".concat(StringUtils.join(requestParameters, "&"));
}
controllerWebServiceEndpoints.add(webServiceEndpoint);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
index c69013b..2bebd2e 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.management.internal.cli.CommandRequest;
import org.apache.geode.management.internal.web.AbstractWebTestCase;
import org.apache.geode.management.internal.web.domain.Link;
@@ -112,7 +112,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
private CommandRequest createCommandRequest(final String command,
final Map<String, String> options) {
- return new TestCommandRequest(command, options, Collections.<String, String>emptyMap(), null);
+ return new TestCommandRequest(command, options, Collections.emptyMap(), null);
}
private CommandRequest createCommandRequest(final String command,
@@ -122,8 +122,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
private CommandRequest createCommandRequest(final String command,
final Map<String, String> options, final byte[][] fileData) {
- return new TestCommandRequest(command, options, Collections.<String, String>emptyMap(),
- fileData);
+ return new TestCommandRequest(command, options, Collections.emptyMap(), fileData);
}
private CommandRequest createCommandRequest(final String command,
@@ -145,12 +144,12 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
@Test
public void testCreateHttpRequest() {
- final Map<String, String> commandOptions = new HashMap<String, String>();
+ final Map<String, String> commandOptions = new HashMap<>();
commandOptions.put("author", "Adams");
commandOptions.put("blankOption", " ");
commandOptions.put("category", "sci-fi");
- commandOptions.put("emptyOption", StringUtils.EMPTY_STRING);
+ commandOptions.put("emptyOption", StringUtils.EMPTY);
commandOptions.put("isbn", "0-123456789");
commandOptions.put("nullOption", null);
commandOptions.put("title", "Hitch Hiker's Guide to the Galaxy");
@@ -182,12 +181,12 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
@Test
public void testCreateHttpRequestWithEnvironmentVariables() {
- final Map<String, String> commandOptions = new HashMap<String, String>(2);
+ final Map<String, String> commandOptions = new HashMap<>(2);
commandOptions.put("name", "ElLibreDeCongress");
commandOptions.put("isbn", "${ISBN}");
- final Map<String, String> environment = new HashMap<String, String>(2);
+ final Map<String, String> environment = new HashMap<>(2);
environment.put("ISBN", "0-987654321");
environment.put("VAR", "test");
@@ -209,7 +208,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
}
@Test
- public void testCreatHttpRequestWithFileData() {
+ public void testCreateHttpRequestWithFileData() {
final Map<String, String> commandOptions = Collections.singletonMap("isbn", "0-123456789");
final byte[][] fileData = {"/path/to/book/content.txt".getBytes(),
@@ -238,7 +237,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
@Test
public void testFindAndResolveLink() throws Exception {
- final Map<String, String> commandOptions = new HashMap<String, String>();
+ final Map<String, String> commandOptions = new HashMap<>();
commandOptions.put("name", "BarnesN'Noble");
@@ -253,7 +252,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
assertNotNull(link);
assertEquals("http://host.domain.com/service/v1/libraries/{name}", toString(link.getHref()));
- commandOptions.put("author", "J.K.Rowlings");
+ commandOptions.put("author", "J.K.Rowling");
link = getOperationInvoker().findLink(createCommandRequest("list-books", commandOptions));
@@ -323,8 +322,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
}
};
- final Object actualResult = operationInvoker.processCommand(
- createCommandRequest("list-libraries", Collections.<String, String>emptyMap()));
+ final Object actualResult = operationInvoker
+ .processCommand(createCommandRequest("list-libraries", Collections.emptyMap()));
assertEquals(expectedResult, actualResult);
}
@@ -353,8 +352,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
protected void printWarning(final String message, final Object... args) {}
};
- final Object actualResult = operationInvoker.processCommand(
- createCommandRequest("get resource", Collections.<String, String>emptyMap()));
+ final Object actualResult = operationInvoker
+ .processCommand(createCommandRequest("get resource", Collections.emptyMap()));
assertEquals(expectedResult, actualResult);
}
@@ -391,8 +390,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
+ "Please try reconnecting or see the GemFire Manager's log file for further details.",
operationInvoker.getBaseUrl(), "test");
- final Object actualResult = operationInvoker.processCommand(
- createCommandRequest("list-libraries", Collections.<String, String>emptyMap()));
+ final Object actualResult = operationInvoker
+ .processCommand(createCommandRequest("list-libraries", Collections.emptyMap()));
assertFalse(operationInvoker.isConnected());
assertEquals(expectedResult, actualResult);
@@ -413,8 +412,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
};
try {
- operationInvoker.processCommand(
- createCommandRequest("get resource", Collections.<String, String>emptyMap()));
+ operationInvoker.processCommand(createCommandRequest("get resource", Collections.emptyMap()));
} catch (RestApiCallForCommandNotFoundException e) {
assertEquals("No REST API call for command (get resource) was found!", e.getMessage());
throw e;
@@ -425,7 +423,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
public void testProcessCommandWhenNotConnected() {
try {
getOperationInvoker()
- .processCommand(createCommandRequest("get-book", Collections.<String, String>emptyMap()));
+ .processCommand(createCommandRequest("get-book", Collections.emptyMap()));
} catch (IllegalStateException e) {
assertEquals(
"Gfsh must be connected to the GemFire Manager in order to process commands remotely!",
@@ -436,7 +434,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
private static class TestCommandRequest extends CommandRequest {
- private final Map<String, String> commandParameters = new TreeMap<String, String>();
+ private final Map<String, String> commandParameters = new TreeMap<>();
private final String command;
[6/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Posted by ji...@apache.org.
GEODE-1994: Overhaul of internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
* geode.internal.lang.StringUtils has been deprecated. In the interim, it has been heavily refactored and extends commons.lang.StringUtils.
*
* Renamed:
* -- EMPTY_STRING -> EMPTY (inherited)
* -- toUpperCase -> upperCase (inherited)
* -- toLowerCase -> lowerCase (inherited)
* -- padEnding -> rightPad (inherited)
*
* Removed:
* -- EMPTY_STRING_ARRAY; usage replaced with commons.lang.ArrayUtils.EMPTY_STRING_ARRAY
* -- SPACES
* -- UTF_8; rare usage replaced with raw string
* -- concat; usage replaced with commons.lang.join, refactoring as necessary.
* -- getLettersOnly
* -- getSpaces
* -- truncate
* -- valueOf; usage refactored to use defaultString
*
* Refactored
* -- defaultIfBlank: previously relied on varargs and could return null. Usage refactored to allow inheritance from commons.
* -- defaultString(s, EMPTY) refactored to use standard signature defaultString(s) for consistency throughout codebase.
* -- isBlank: usage refactored to resolve discrepancies with commons.lang.isBlank, which is now inherited.
* -- isEmpty: usage refactored to resolve discrepancies with commons.lang.isEmpty, which is now inherited.
*
* Code Cleanup:
* -- Many uses of !isBlank -> isNotBlank
* -- Changes suggested by Inspections on most touched files.
* -- Explicit <T> -> <> when type is inferable
* -- while loops operating on iterators converted to for each loops
* -- for loops operating on array indices converted to for each loops
* -- Various string typos corrected.
* -- isEmpty(s.trim()) -> isBlank(s)
* -- s.trim().isEmpty() -> isEmpty(s)
* -- Removed some instances of 'dead' code
* -- Optimized imports in every touched file
*
* Qualitative Changes:
* -- The following functions now throw an error when called with a null string input:
* -- * LocatorLauncher.Builder.setMemberName
* -- * ServerLauncher.Builder.setMemberName
* -- * ServerLauncher.Builder.setHostnameForClients
* -- (Unit tests added to capture these changes)
*
* Notes:
* -- StringUtils.wraps may be inherited from Apache Commons when the dependency is updated.
* -- AbstractLauncher.getMember has the documented behavior of returning null when both MemberName and ID are blank. Is this the best behavior for this method?
* this closes #521
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d16d192b
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d16d192b
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d16d192b
Branch: refs/heads/develop
Commit: d16d192b22f2932ac95780f18e92f0aece730240
Parents: 9af854a
Author: Patrick Rhomberg <pr...@pivotal.io>
Authored: Wed May 17 16:57:07 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri May 19 10:29:16 2017 -0700
----------------------------------------------------------------------
.../LauncherLifecycleCommandsDUnitTest.java | 77 ++--
.../commands/LauncherLifecycleCommandsTest.java | 61 +--
.../web/controllers/RestAPITestBase.java | 54 +--
.../internal/locator/LocatorStatusResponse.java | 32 +-
.../query/internal/AttributeDescriptor.java | 70 +---
.../cache/query/internal/NWayMergeResults.java | 31 +-
.../geode/distributed/AbstractLauncher.java | 27 +-
.../geode/distributed/LocatorLauncher.java | 58 ++-
.../geode/distributed/ServerLauncher.java | 72 ++--
.../internal/ClusterConfigurationService.java | 64 ++--
.../distributed/internal/InternalLocator.java | 46 +--
.../membership/gms/membership/GMSJoinLeave.java | 67 ++--
.../geode/internal/InternalDataSerializer.java | 134 +++----
.../admin/remote/RemoteTransportConfig.java | 25 +-
.../cache/ClusterConfigurationLoader.java | 47 ++-
.../geode/internal/cache/EntryEventImpl.java | 20 +-
.../internal/cache/tier/sockets/HandShake.java | 85 ++---
.../apache/geode/internal/lang/StringUtils.java | 268 ++-----------
.../apache/geode/internal/lang/SystemUtils.java | 4 +-
.../internal/process/FileProcessController.java | 11 +-
.../geode/internal/process/signal/Signal.java | 4 +-
.../security/IntegratedSecurityService.java | 10 +-
.../apache/geode/internal/util/ArrayUtils.java | 11 +-
.../org/apache/geode/internal/util/IOUtils.java | 6 +-
.../geode/management/internal/AgentUtil.java | 8 +-
.../geode/management/internal/JettyHelper.java | 27 +-
.../management/internal/ManagementAgent.java | 60 ++-
.../geode/management/internal/RestAgent.java | 21 +-
.../geode/management/internal/SSLUtil.java | 5 +-
.../internal/beans/DistributedSystemBridge.java | 175 ++++-----
.../internal/beans/DistributedSystemMBean.java | 11 +-
.../internal/beans/ManagementAdapter.java | 82 ++--
.../internal/beans/QueryDataFunction.java | 90 ++---
.../geode/management/internal/cli/CliUtil.java | 48 +--
.../cli/commands/AbstractCommandsSupport.java | 15 +-
.../internal/cli/commands/ConfigCommands.java | 40 +-
.../CreateAlterDestroyRegionCommands.java | 187 ++++------
...xportImportClusterConfigurationCommands.java | 34 +-
.../internal/cli/commands/IndexCommands.java | 25 +-
.../cli/commands/LauncherLifecycleCommands.java | 372 +++++++------------
.../internal/cli/commands/ShellCommands.java | 10 +-
.../cli/converters/FilePathStringConverter.java | 2 +-
.../converters/GatewaySenderIdConverter.java | 15 +-
.../internal/cli/domain/DiskStoreDetails.java | 10 +-
.../internal/cli/domain/IndexDetails.java | 14 +-
.../functions/DescribeDiskStoreFunction.java | 13 +-
.../FetchSharedConfigurationStatusFunction.java | 2 +-
.../cli/functions/RegionCreateFunction.java | 11 +-
.../management/internal/cli/help/HelpBlock.java | 4 +-
.../management/internal/cli/help/Helper.java | 4 +-
.../internal/cli/result/ResultBuilder.java | 18 +-
.../internal/cli/result/TableBuilder.java | 30 +-
.../internal/cli/shell/GfshConfig.java | 6 +-
.../cli/shell/GfshExecutionStrategy.java | 16 +-
.../internal/cli/shell/JmxOperationInvoker.java | 4 +-
.../internal/cli/util/CommandStringBuilder.java | 4 +-
.../configuration/domain/XmlEntity.java | 50 ++-
.../messages/ConfigurationRequest.java | 12 +-
.../messages/ConfigurationResponse.java | 22 +-
.../internal/configuration/utils/XmlUtils.java | 33 +-
.../controllers/AbstractCommandsController.java | 62 ++--
.../controllers/ConfigCommandsController.java | 10 +-
.../web/controllers/DataCommandsController.java | 4 +-
.../controllers/DeployCommandsController.java | 13 +-
.../DiskStoreCommandsController.java | 16 +-
.../DurableClientCommandsController.java | 14 +-
.../web/controllers/ExportLogController.java | 2 +-
.../controllers/FunctionCommandsController.java | 10 +-
.../MiscellaneousCommandsController.java | 4 +-
.../web/controllers/PdxCommandsController.java | 9 +-
.../controllers/QueueCommandsController.java | 7 +-
.../controllers/RegionCommandsController.java | 11 +-
.../controllers/ShellCommandsController.java | 34 +-
.../web/controllers/WanCommandsController.java | 55 ++-
.../management/internal/web/domain/Link.java | 12 +-
.../internal/web/domain/LinkIndex.java | 6 +-
.../internal/web/http/HttpHeader.java | 4 +-
.../web/shell/RestHttpOperationInvoker.java | 4 +-
.../internal/web/util/ConvertUtils.java | 11 +-
.../management/internal/web/util/UriUtils.java | 4 +-
.../cache/client/internal/LocatorTestBase.java | 40 +-
.../AbstractLauncherIntegrationTestCase.java | 2 +-
.../geode/distributed/AbstractLauncherTest.java | 24 +-
.../LocatorLauncherIntegrationTest.java | 14 +-
.../geode/distributed/LocatorLauncherTest.java | 61 ++-
.../ServerLauncherIntegrationTest.java | 14 +-
.../geode/distributed/ServerLauncherTest.java | 40 +-
.../internal/lang/ClassUtilsJUnitTest.java | 15 +-
.../internal/lang/StringUtilsJUnitTest.java | 244 +-----------
.../internal/util/CollectionUtilsJUnitTest.java | 96 ++---
.../AbstractCommandsSupportJUnitTest.java | 40 +-
.../cli/commands/ListIndexCommandDUnitTest.java | 45 ++-
.../internal/configuration/ClusterConfig.java | 14 +-
.../dunit/rules/GfshShellConnectionRule.java | 2 +-
.../internal/cli/LuceneIndexCommands.java | 45 +--
.../functions/LuceneCreateIndexFunction.java | 3 +-
.../cli/LuceneIndexCommandsJUnitTest.java | 61 +--
.../pulse/testbed/PropMockDataUpdater.java | 17 +-
.../geodefunctions/RetrieveRegionFunction.java | 20 +-
.../internal/web/AbstractWebTestCase.java | 14 +-
.../ShellCommandsControllerJUnitTest.java | 38 +-
.../RestHttpOperationInvokerJUnitTest.java | 40 +-
102 files changed, 1648 insertions(+), 2297 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
index 5277e57..27bc098 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
@@ -14,41 +14,13 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Wait.*;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.TimeUnit;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
+import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_ID;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertFalse;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.assertTrue;
+import static org.apache.geode.test.dunit.Wait.waitForCriterion;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
@@ -79,6 +51,37 @@ import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.test.dunit.WaitCriterion;
import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.TimeUnit;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
/**
* The LauncherLifecycleCommandsDUnitTest class is a test suite of integration tests testing the
@@ -389,7 +392,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertTrue(resultString,
resultString
.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE,
- StringUtils.EMPTY_STRING, gemfirePropertiesPathname)));
+ StringUtils.EMPTY, gemfirePropertiesPathname)));
}
/**
@@ -525,7 +528,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertTrue(resultString,
resultString
.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE,
- StringUtils.EMPTY_STRING, gemfirePropertiesFile)));
+ StringUtils.EMPTY, gemfirePropertiesFile)));
}
@Test
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
index 0554f69..2a1662e 100755
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
@@ -14,33 +14,42 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-
-import org.apache.geode.distributed.LocatorLauncher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.GemFireException;
import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.LocatorLauncher;
import org.apache.geode.distributed.ServerLauncher;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.DistributionLocator;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.lang.SystemUtils;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Stack;
/**
* The LauncherLifecycleCommandsTest class is a test suite of test cases testing the contract and
@@ -77,7 +86,7 @@ public class LauncherLifecycleCommandsTest {
assertTrue(commandLine.isEmpty());
- getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, StringUtils.EMPTY_STRING);
+ getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, StringUtils.EMPTY);
assertTrue(commandLine.isEmpty());
@@ -106,7 +115,7 @@ public class LauncherLifecycleCommandsTest {
gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
gemfireProperties.setProperty(LOG_LEVEL, "config");
- gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
+ gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY);
gemfireProperties.setProperty(MCAST_PORT, "0");
gemfireProperties.setProperty(NAME, "machine");
@@ -144,7 +153,7 @@ public class LauncherLifecycleCommandsTest {
gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
gemfireProperties.setProperty(LOG_LEVEL, "config");
- gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
+ gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY);
gemfireProperties.setProperty(MCAST_PORT, "0");
gemfireProperties.setProperty(NAME, "machine");
@@ -182,7 +191,7 @@ public class LauncherLifecycleCommandsTest {
assertTrue(commandLine.isEmpty());
- getLauncherLifecycleCommands().addInitialHeap(commandLine, StringUtils.EMPTY_STRING);
+ getLauncherLifecycleCommands().addInitialHeap(commandLine, StringUtils.EMPTY);
assertTrue(commandLine.isEmpty());
@@ -255,7 +264,7 @@ public class LauncherLifecycleCommandsTest {
assertTrue(commandLine.isEmpty());
- getLauncherLifecycleCommands().addMaxHeap(commandLine, StringUtils.EMPTY_STRING);
+ getLauncherLifecycleCommands().addMaxHeap(commandLine, StringUtils.EMPTY);
assertTrue(commandLine.isEmpty());
@@ -621,11 +630,11 @@ public class LauncherLifecycleCommandsTest {
}
private String toClasspath(final String... jarFilePathnames) {
- String classpath = StringUtils.EMPTY_STRING;
+ String classpath = StringUtils.EMPTY;
if (jarFilePathnames != null) {
for (final String jarFilePathname : jarFilePathnames) {
- classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
+ classpath += (classpath.isEmpty() ? StringUtils.EMPTY : File.pathSeparator);
classpath += jarFilePathname;
}
}
@@ -637,7 +646,7 @@ public class LauncherLifecycleCommandsTest {
String path = "";
for (Object pathElement : pathElements) {
- path += (path.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
+ path += (path.isEmpty() ? StringUtils.EMPTY : File.pathSeparator);
path += pathElement;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPITestBase.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPITestBase.java
index f2e90a4..4529f2c 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPITestBase.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPITestBase.java
@@ -14,36 +14,21 @@
*/
package org.apache.geode.rest.internal.web.controllers;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-import org.junit.experimental.categories.Category;
-
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.fail;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.execute.FunctionService;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.AvailablePortHelper;
import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.AgentUtil;
import org.apache.geode.rest.internal.web.RestFunctionTemplate;
import org.apache.geode.test.dunit.Host;
@@ -51,6 +36,25 @@ import org.apache.geode.test.dunit.Invoke;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+import org.junit.experimental.categories.Category;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
@Category(DistributedTest.class)
class RestAPITestBase extends JUnit4DistributedTestCase {
@@ -168,7 +172,7 @@ class RestAPITestBase extends JUnit4DistributedTestCase {
HttpPost post = new HttpPost(restString);
post.addHeader("Content-Type", "application/json");
post.addHeader("Accept", "application/json");
- if (jsonBody != null && !StringUtils.isEmpty(jsonBody)) {
+ if (StringUtils.isNotEmpty(jsonBody)) {
StringEntity jsonStringEntity = new StringEntity(jsonBody, ContentType.DEFAULT_TEXT);
post.setEntity(jsonStringEntity);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
index d531cc1..677db4d 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
@@ -15,6 +15,13 @@
package org.apache.geode.cache.client.internal.locator;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.lang.ObjectUtils;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.process.PidUnavailableException;
+import org.apache.geode.internal.process.ProcessUtils;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -24,13 +31,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.process.PidUnavailableException;
-import org.apache.geode.internal.process.ProcessUtils;
-
/**
* The LocatorStatusResponse class...
* </p>
@@ -101,7 +101,7 @@ public class LocatorStatusResponse extends ServerLocationResponse {
@SuppressWarnings("unchecked")
public List<String> getJvmArgs() {
return Collections
- .unmodifiableList(ObjectUtils.defaultIfNull(jvmArgs, Collections.<String>emptyList()));
+ .unmodifiableList(ObjectUtils.defaultIfNull(jvmArgs, Collections.emptyList()));
}
public Integer getPid() {
@@ -162,12 +162,12 @@ public class LocatorStatusResponse extends ServerLocationResponse {
}
protected void readWorkingDirectory(final DataInput in) throws IOException {
- this.workingDirectory = StringUtils.defaultIfBlank(in.readUTF());
+ this.workingDirectory = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readJvmArguments(final DataInput in) throws IOException {
final int length = in.readInt();
- final List<String> jvmArgs = new ArrayList<String>(length);
+ final List<String> jvmArgs = new ArrayList<>(length);
for (int index = 0; index < length; index++) {
jvmArgs.add(in.readUTF());
}
@@ -175,23 +175,23 @@ public class LocatorStatusResponse extends ServerLocationResponse {
}
protected void readClasspath(final DataInput in) throws IOException {
- this.classpath = StringUtils.defaultIfBlank(in.readUTF());
+ this.classpath = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readGemFireVersion(final DataInput in) throws IOException {
- this.gemfireVersion = StringUtils.defaultIfBlank(in.readUTF());
+ this.gemfireVersion = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readJavaVersion(final DataInput in) throws IOException {
- this.javaVersion = StringUtils.defaultIfBlank(in.readUTF());
+ this.javaVersion = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readLogFile(final DataInput in) throws IOException {
- this.logFile = StringUtils.defaultIfBlank(in.readUTF());
+ this.logFile = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readHost(final DataInput in) throws IOException {
- this.host = StringUtils.defaultIfBlank(in.readUTF());
+ this.host = StringUtils.nullifyIfBlank(in.readUTF());
}
protected void readPort(final DataInput in) throws IOException {
@@ -200,7 +200,7 @@ public class LocatorStatusResponse extends ServerLocationResponse {
}
protected void readName(final DataInput in) throws IOException {
- this.name = StringUtils.defaultIfBlank(in.readUTF());
+ this.name = StringUtils.nullifyIfBlank(in.readUTF());
}
@Override
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
index f40ab3e..5bfba0e 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
@@ -15,6 +15,19 @@
package org.apache.geode.cache.query.internal;
+import org.apache.geode.cache.EntryDestroyedException;
+import org.apache.geode.cache.query.NameNotFoundException;
+import org.apache.geode.cache.query.QueryInvocationTargetException;
+import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.cache.query.types.ObjectType;
+import org.apache.geode.internal.cache.Token;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.pdx.PdxSerializationException;
+import org.apache.geode.pdx.internal.FieldNotFoundInPdxVersion;
+import org.apache.geode.pdx.internal.PdxInstanceImpl;
+
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -28,19 +41,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.geode.cache.EntryDestroyedException;
-import org.apache.geode.cache.query.NameNotFoundException;
-import org.apache.geode.cache.query.QueryInvocationTargetException;
-import org.apache.geode.cache.query.QueryService;
-import org.apache.geode.cache.query.types.ObjectType;
-import org.apache.geode.internal.cache.Token;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.pdx.PdxInstance;
-import org.apache.geode.pdx.PdxSerializationException;
-import org.apache.geode.pdx.internal.FieldNotFoundInPdxVersion;
-import org.apache.geode.pdx.internal.PdxInstanceImpl;
-import org.apache.geode.pdx.JSONFormatter;
-
/**
* Utility for managing an attribute
*
@@ -137,25 +137,6 @@ public class AttributeDescriptor {
}
- /* this method is not yet used. Here to support Update statements */
- // returns either null or UNDEFINED
- /*
- * public Object write(Object target, Object newValue) throws PathEvaluationException { if (target
- * == null) return QueryService.UNDEFINED;
- *
- *
- * Class targetType = target.getClass(); Class argType = newValue == null ? null :
- * newValue.getClass(); Member m = getWriteMember(targetType, argType); if (m == null) throw new
- * PathEvaluationException(LocalizedStrings.AttributeDescriptor_NO_UPDATE_PATH_MAPPING_FOUND_FOR_0
- * .toLocalizedString(_name)); try { if (m instanceof Method) { try { ((Method)m).invoke(target,
- * new Object[] { newValue }); return null; } catch (InvocationTargetException e) { throw new
- * PathEvaluationException(e.getTargetException()); } } else { ((Field)m).set(target, newValue);
- * return null; } } catch (IllegalAccessException e) { throw new PathEvaluationException(e)); }
- *
- * }
- */
-
-
Member getReadMember(ObjectType targetType) throws NameNotFoundException {
return getReadMember(targetType.resolveClass());
}
@@ -186,14 +167,6 @@ public class AttributeDescriptor {
}
- /*
- * Not yet used, Here to support Update statements private Member getWriteMember(Class targetType,
- * Class argType) { // mapping: public field (same name), method (setAttribute(val)), // method
- * attribute(val) Member m; m = getWriteField(targetType, argType); if (m != null) return m;
- * return getWriteMethod(targetType, argType); }
- */
-
-
private Field getReadField(Class targetType) {
try {
@@ -203,11 +176,6 @@ public class AttributeDescriptor {
}
}
- /*
- * not yet used private Field getWriteField(Class targetType, Class argType) { try { return
- * targetType.getField(_name); } catch (NoSuchFieldException e) { return null; } }
- */
-
private Method getReadMethod(Class targetType) {
@@ -219,12 +187,6 @@ public class AttributeDescriptor {
return getReadMethod(targetType, _name);
}
- /*
- * not yet used private Method getWriteMethod(Class targetType, Class argType) { Method m; String
- * beanMethod = "set" + _name.substring(0,1).toUpperCase() + _name.substring(1); m =
- * getWriteMethod(targetType, argType, beanMethod); if (m != null) return m; return
- * getWriteMethod(targetType, argType, _name); }
- */
private Method getReadMethod(Class targetType, String methodName) {
@@ -236,12 +198,6 @@ public class AttributeDescriptor {
}
}
- /*
- * not yet used private Method getWriteMethod(Class targetType, Class argType, String methodName)
- * { try { // @todo look up maximally specific method based on argType return
- * targetType.getMethod(methodName, new Class[] { argType }); } catch (NoSuchMethodException e) {
- * return null; } }
- */
/**
* reads field value from a PdxInstance
*
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/cache/query/internal/NWayMergeResults.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/NWayMergeResults.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/NWayMergeResults.java
index 4e52a67..1a267d8 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/NWayMergeResults.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/NWayMergeResults.java
@@ -14,19 +14,6 @@
*/
package org.apache.geode.cache.query.internal;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.AbstractCollection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
import org.apache.geode.DataSerializer;
import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.cache.query.Struct;
@@ -40,6 +27,19 @@ import org.apache.geode.internal.HeapDataOutputStream;
import org.apache.geode.internal.HeapDataOutputStream.LongUpdater;
import org.apache.geode.internal.Version;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
/**
* The n - way merge results returns a sorted results on the cumulative sorted results for
* partitioned region based query
@@ -210,11 +210,6 @@ public class NWayMergeResults<E> implements SelectResults<E>, Ordered, DataSeria
}
- /*
- * @Override public boolean isEmpty() { boolean isEmpty = true; for (SelectResults<E> result :
- * this.sortedResults) { isEmpty = result.isEmpty(); if (!isEmpty) { break; } } return isEmpty;
- * }
- */
@Override
public Iterator<E> iterator() {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
index feba893..007a990 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
@@ -37,14 +37,11 @@ import org.apache.geode.management.internal.cli.json.GfJsonObject;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.net.BindException;
import java.net.InetAddress;
import java.net.URL;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -144,7 +141,7 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
* @see java.util.Properties
*/
protected static boolean isSet(final Properties properties, final String propertyName) {
- return !StringUtils.isBlank(properties.getProperty(propertyName));
+ return StringUtils.isNotBlank(properties.getProperty(propertyName));
}
/**
@@ -243,7 +240,7 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
distributedSystemProperties.putAll(defaults);
}
- if (!StringUtils.isBlank(getMemberName())) {
+ if (StringUtils.isNotBlank(getMemberName())) {
distributedSystemProperties.setProperty(NAME, getMemberName());
}
@@ -291,7 +288,13 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
* @see #getMemberId()
*/
public String getMember() {
- return StringUtils.defaultIfBlank(getMemberName(), getMemberId());
+ if (StringUtils.isNotBlank(getMemberName())) {
+ return getMemberName();
+ }
+ if (StringUtils.isNotBlank(getMemberId())) {
+ return getMemberId();
+ }
+ return null;
}
/**
@@ -501,7 +504,7 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
// TODO refactor the logic in this method into a DateTimeFormatUtils class
protected static String toDaysHoursMinutesSeconds(final Long milliseconds) {
- final StringBuilder buffer = new StringBuilder(StringUtils.EMPTY_STRING);
+ final StringBuilder buffer = new StringBuilder();
if (milliseconds != null) {
long millisecondsRemaining = milliseconds;
@@ -569,7 +572,7 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
* @return a String value containing the JSON representation of this state object.
*/
public String toJson() {
- final Map<String, Object> map = new HashMap<String, Object>();
+ final Map<String, Object> map = new HashMap<>();
map.put(JSON_CLASSPATH, getClasspath());
map.put(JSON_GEMFIREVERSION, getGemFireVersion());
map.put(JSON_HOST, getHost());
@@ -778,12 +781,12 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
// the value of a Number as a String, or "" if null
protected String toString(final Number value) {
- return StringUtils.valueOf(value, "");
+ return StringUtils.defaultString(value);
}
// a String concatenation of all values separated by " "
protected String toString(final Object... values) {
- return StringUtils.concat(values, " ");
+ return values == null ? "" : StringUtils.join(values, " ");
}
// the value of the String, or "" if value is null
@@ -805,8 +808,8 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
private final String description;
Status(final String description) {
- assert !StringUtils.isBlank(description) : "The Status description must be specified!";
- this.description = StringUtils.toLowerCase(description);
+ assert StringUtils.isNotBlank(description) : "The Status description must be specified!";
+ this.description = StringUtils.lowerCase(description);
}
/**
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
index 641e009..68aa9db 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
@@ -15,32 +15,42 @@
package org.apache.geode.distributed;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import org.apache.geode.cache.client.internal.locator.*;
+import org.apache.geode.cache.client.internal.locator.LocatorStatusRequest;
+import org.apache.geode.cache.client.internal.locator.LocatorStatusResponse;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.DistributionConfigImpl;
import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.tcpserver.*;
+import org.apache.geode.distributed.internal.tcpserver.TcpClient;
import org.apache.geode.internal.DistributionLocator;
import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.internal.lang.ObjectUtils;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.lang.SystemUtils;
-import org.apache.geode.internal.process.*;
+import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.internal.process.ConnectionFailedException;
+import org.apache.geode.internal.process.ControlNotificationHandler;
+import org.apache.geode.internal.process.ControllableProcess;
+import org.apache.geode.internal.process.FileAlreadyExistsException;
+import org.apache.geode.internal.process.MBeanInvocationFailedException;
+import org.apache.geode.internal.process.PidUnavailableException;
+import org.apache.geode.internal.process.ProcessController;
+import org.apache.geode.internal.process.ProcessControllerFactory;
+import org.apache.geode.internal.process.ProcessControllerParameters;
+import org.apache.geode.internal.process.ProcessLauncherContext;
+import org.apache.geode.internal.process.ProcessType;
+import org.apache.geode.internal.process.ProcessUtils;
+import org.apache.geode.internal.process.StartupStatusListener;
+import org.apache.geode.internal.process.UnableToControlProcessException;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.lang.AttachAPINotFoundException;
import org.apache.geode.management.internal.cli.json.GfJsonArray;
import org.apache.geode.management.internal.cli.json.GfJsonException;
import org.apache.geode.management.internal.cli.json.GfJsonObject;
-import joptsimple.OptionException;
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -48,12 +58,23 @@ import java.lang.management.ManagementFactory;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import joptsimple.OptionException;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
/**
* The LocatorLauncher class is a launcher for a GemFire Locator.
@@ -1563,7 +1584,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* @see #getHostnameForClients()
*/
public Builder setHostnameForClients(final String hostnameForClients) {
- if (StringUtils.isEmpty(StringUtils.trim(hostnameForClients))) {
+ if (StringUtils.isBlank(hostnameForClients)) {
throw new IllegalArgumentException(
LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
.toLocalizedString());
@@ -1591,7 +1612,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* @see #getMemberName()
*/
public Builder setMemberName(final String memberName) {
- if (StringUtils.isEmpty(StringUtils.trim(memberName))) {
+ if (StringUtils.isBlank(memberName)) {
throw new IllegalArgumentException(
LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE
.toLocalizedString("Locator"));
@@ -1707,7 +1728,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
}
boolean isWorkingDirectorySpecified() {
- return !StringUtils.isBlank(this.workingDirectory);
+ return StringUtils.isNotBlank(this.workingDirectory);
}
/**
@@ -1931,7 +1952,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* option.
*/
public boolean hasOption(final String option) {
- return getOptions().contains(StringUtils.toLowerCase(option));
+ return getOptions().contains(StringUtils.lowerCase(option));
}
/**
@@ -2043,8 +2064,9 @@ public class LocatorLauncher extends AbstractLauncher<String> {
if (logFile != null && logFile.isFile()) {
final String logFileCanonicalPath =
IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
- if (!StringUtils.isBlank(logFileCanonicalPath)) { // this is probably not need but a safe
- // check none-the-less.
+ if (StringUtils.isNotBlank(logFileCanonicalPath)) { // this is probably not need but a
+ // safe
+ // check none-the-less.
return logFileCanonicalPath;
}
}
@@ -2056,7 +2078,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
if (InternalLocator.hasLocator()) {
final InternalLocator locator = InternalLocator.getLocator();
final String portAsString = String.valueOf(locator.getPort());
- if (!StringUtils.isBlank(portAsString)) {
+ if (StringUtils.isNotBlank(portAsString)) {
return portAsString;
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
index b2d0151..acd5e8a 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
@@ -15,33 +15,9 @@
package org.apache.geode.distributed;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.ServiceLoader;
-import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import joptsimple.OptionException;
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_BIND_ADDRESS;
import org.apache.geode.SystemFailure;
import org.apache.geode.cache.Cache;
@@ -87,6 +63,30 @@ import org.apache.geode.pdx.PdxSerializer;
import org.apache.geode.security.AuthenticationRequiredException;
import org.apache.geode.security.GemFireSecurityException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ServiceLoader;
+import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import joptsimple.OptionException;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+
/**
* The ServerLauncher class is a launcher class with main method to start a GemFire Server (implying
* a GemFire Cache Server process).
@@ -366,7 +366,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
final StringBuilder buffer = new StringBuilder(ServerState.getServerBindAddressAsString(this));
final String serverPort = ServerState.getServerPortAsString(this);
- if (!StringUtils.isBlank(serverPort)) {
+ if (StringUtils.isNotBlank(serverPort)) {
buffer.append("[").append(serverPort).append("]");
}
@@ -590,7 +590,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* configuration meta-data.
*/
public boolean isSpringXmlLocationSpecified() {
- return !StringUtils.isBlank(this.springXmlLocation);
+ return StringUtils.isNotBlank(this.springXmlLocation);
}
/**
@@ -1956,7 +1956,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* @see #getMemberName()
*/
public Builder setMemberName(final String memberName) {
- if (StringUtils.isEmpty(StringUtils.trim(memberName))) {
+ if (StringUtils.isBlank(memberName)) {
throw new IllegalArgumentException(
LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE
.toLocalizedString("Server"));
@@ -2496,7 +2496,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
private final String name;
Command(final String name, final String... options) {
- assert !StringUtils.isBlank(name) : "The name of the command must be specified!";
+ assert StringUtils.isNotBlank(name) : "The name of the command must be specified!";
this.name = name;
this.options = (options != null ? Collections.unmodifiableList(Arrays.asList(options))
: Collections.<String>emptyList());
@@ -2572,7 +2572,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* option.
*/
public boolean hasOption(final String option) {
- return getOptions().contains(StringUtils.toLowerCase(option));
+ return getOptions().contains(StringUtils.lowerCase(option));
}
/**
@@ -2678,7 +2678,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
if (logFile != null && logFile.isFile()) {
final String logFileCanonicalPath =
IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
- if (!StringUtils.isBlank(logFileCanonicalPath)) {
+ if (StringUtils.isNotBlank(logFileCanonicalPath)) {
return logFileCanonicalPath;
}
}
@@ -2696,7 +2696,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
if (csList != null && !csList.isEmpty()) {
final CacheServer cs = csList.get(0);
final String serverBindAddressAsString = cs.getBindAddress();
- if (!StringUtils.isBlank(serverBindAddressAsString)) {
+ if (StringUtils.isNotBlank(serverBindAddressAsString)) {
return serverBindAddressAsString;
}
}
@@ -2714,13 +2714,13 @@ public class ServerLauncher extends AbstractLauncher<String> {
if (csList != null && !csList.isEmpty()) {
final CacheServer cs = csList.get(0);
final String portAsString = String.valueOf(cs.getPort());
- if (!StringUtils.isBlank(portAsString)) {
+ if (StringUtils.isNotBlank(portAsString)) {
return portAsString;
}
}
}
- return (launcher.isDisableDefaultServer() ? StringUtils.EMPTY_STRING
+ return (launcher.isDisableDefaultServer() ? StringUtils.EMPTY
: launcher.getServerPortAsString());
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
index 10623b4..d990015 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
@@ -14,41 +14,14 @@
*/
package org.apache.geode.distributed.internal;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Path;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.logging.log4j.Logger;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.CancelException;
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.CacheLoaderException;
@@ -69,7 +42,6 @@ import org.apache.geode.internal.cache.persistence.PersistentMemberID;
import org.apache.geode.internal.cache.persistence.PersistentMemberManager;
import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.configuration.callbacks.ConfigurationChangeListener;
@@ -81,6 +53,34 @@ import org.apache.geode.management.internal.configuration.messages.Configuration
import org.apache.geode.management.internal.configuration.messages.ConfigurationResponse;
import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse;
import org.apache.geode.management.internal.configuration.utils.XmlUtils;
+import org.apache.logging.log4j.Logger;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Path;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactoryConfigurationError;
@SuppressWarnings({"deprecation", "unchecked"})
public class ClusterConfigurationService {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index ad5e04d..6500385 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -14,26 +14,11 @@
*/
package org.apache.geode.distributed.internal;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.logging.log4j.Logger;
+import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.CancelException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.GemFireCache;
@@ -69,7 +54,6 @@ import org.apache.geode.internal.logging.LoggingThreadGroup;
import org.apache.geode.internal.logging.log4j.LocalizedMessage;
import org.apache.geode.internal.logging.log4j.LogMarker;
import org.apache.geode.internal.logging.log4j.LogWriterAppenders;
-import org.apache.geode.internal.logging.log4j.LogWriterLogger;
import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.net.SocketCreatorFactory;
import org.apache.geode.management.internal.JmxManagerLocator;
@@ -81,6 +65,22 @@ import org.apache.geode.management.internal.configuration.handlers.SharedConfigu
import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusRequest;
import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse;
+import org.apache.logging.log4j.Logger;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* Provides the implementation of a distribution {@code Locator} as well as internal-only
@@ -675,7 +675,7 @@ public class InternalLocator extends Locator implements ConnectListener {
// this.logger.config("ensuring that this locator is in the locators list");
boolean setLocatorsProp = false;
String locatorsProp = this.config.getLocators();
- if (locatorsProp != null && !locatorsProp.trim().isEmpty()) {
+ if (StringUtils.isNotBlank(locatorsProp)) {
if (!locatorsProp.contains(thisLocator)) {
locatorsProp = locatorsProp + ',' + thisLocator;
setLocatorsProp = true;
@@ -756,7 +756,7 @@ public class InternalLocator extends Locator implements ConnectListener {
*
* @since GemFire 5.7
*/
- void endStartLocator(InternalDistributedSystem distributedSystem) throws UnknownHostException {
+ void endStartLocator(InternalDistributedSystem distributedSystem) {
this.env = null;
if (distributedSystem == null) {
distributedSystem = InternalDistributedSystem.getConnectedInstance();
@@ -1262,7 +1262,7 @@ public class InternalLocator extends Locator implements ConnectListener {
public Object processRequest(Object request) throws IOException {
long giveup = 0;
while (giveup == 0 || System.currentTimeMillis() < giveup) {
- TcpHandler handler = null;
+ TcpHandler handler;
if (request instanceof PeerLocatorRequest) {
handler = this.handlerMapping.get(PeerLocatorRequest.class);
} else {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 9dc7fe2..478c4e8 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -14,33 +14,20 @@
*/
package org.apache.geode.distributed.internal.membership.gms.membership;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.distributed.internal.membership.gms.ServiceConfig.*;
-import static org.apache.geode.internal.DataSerializableFixedID.*;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TimerTask;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.logging.log4j.Logger;
-
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.distributed.internal.membership.gms.ServiceConfig.MEMBER_REQUEST_COLLECTION_INTERVAL;
+import static org.apache.geode.internal.DataSerializableFixedID.FIND_COORDINATOR_REQ;
+import static org.apache.geode.internal.DataSerializableFixedID.FIND_COORDINATOR_RESP;
+import static org.apache.geode.internal.DataSerializableFixedID.INSTALL_VIEW_MESSAGE;
+import static org.apache.geode.internal.DataSerializableFixedID.JOIN_REQUEST;
+import static org.apache.geode.internal.DataSerializableFixedID.JOIN_RESPONSE;
+import static org.apache.geode.internal.DataSerializableFixedID.LEAVE_REQUEST_MESSAGE;
+import static org.apache.geode.internal.DataSerializableFixedID.NETWORK_PARTITION_MESSAGE;
+import static org.apache.geode.internal.DataSerializableFixedID.REMOVE_MEMBER_REQUEST;
+import static org.apache.geode.internal.DataSerializableFixedID.VIEW_ACK_MESSAGE;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.GemFireConfigException;
import org.apache.geode.SystemConnectException;
import org.apache.geode.distributed.DistributedMember;
@@ -72,6 +59,28 @@ import org.apache.geode.internal.Version;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.security.AuthenticationRequiredException;
import org.apache.geode.security.GemFireSecurityException;
+import org.apache.logging.log4j.Logger;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TimerTask;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* GMSJoinLeave handles membership communication with other processes in the distributed system. It
@@ -1627,8 +1636,8 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
this.services = s;
DistributionConfig dc = services.getConfig().getDistributionConfig();
- if (dc.getMcastPort() != 0 && dc.getLocators().trim().isEmpty()
- && dc.getStartLocator().trim().isEmpty()) {
+ if (dc.getMcastPort() != 0 && StringUtils.isBlank(dc.getLocators())
+ && StringUtils.isBlank(dc.getStartLocator())) {
throw new GemFireConfigException("Multicast cannot be configured for a non-distributed cache."
+ " Please configure the locator services for this cache using " + LOCATORS + " or "
+ START_LOCATOR + ".");
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
index 78b2944..019c35c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
@@ -14,56 +14,7 @@
*/
package org.apache.geode.internal;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.EOFException;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.NotSerializableException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.io.UTFDataFormatException;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetAddress;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.CancelException;
import org.apache.geode.CanonicalInstantiator;
import org.apache.geode.DataSerializable;
@@ -115,6 +66,55 @@ import org.apache.geode.pdx.internal.PdxReaderImpl;
import org.apache.geode.pdx.internal.PdxType;
import org.apache.geode.pdx.internal.PdxWriterImpl;
import org.apache.geode.pdx.internal.TypeRegistry;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.io.UTFDataFormatException;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.Vector;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
/**
* Contains static methods for data serializing instances of internal GemFire classes. It also
@@ -879,8 +879,8 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
// send it to cache servers if it is a client
sendRegistrationMessageToServers(s);
}
- // send it to all cache clients irelevent of distribute
- // bridge servers send it all the clients irelevent of
+ // send it to all cache clients irrelevant of distribute
+ // bridge servers send it all the clients irrelevant of
// originator VM
sendRegistrationMessageToClients(s);
@@ -918,7 +918,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
private static void register(String className, boolean distribute,
SerializerAttributesHolder holder) {
- if (className == null || className.trim().isEmpty()) {
+ if (StringUtils.isBlank(className)) {
throw new IllegalArgumentException("Class name cannot be null or empty.");
}
@@ -1062,9 +1062,9 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
if (o instanceof DataSerializer) {
DataSerializer s = (DataSerializer) o;
Class[] classes = s.getSupportedClasses();
- for (int i = 0; i < classes.length; i++) {
- classesToSerializers.remove(classes[i].getName(), s);
- supportedClassesToHolders.remove(classes[i].getName());
+ for (Class aClass : classes) {
+ classesToSerializers.remove(aClass.getName(), s);
+ supportedClassesToHolders.remove(aClass.getName());
}
dsClassesToHolders.remove(s.getClass().getName());
idsToHolders.remove(idx);
@@ -1185,7 +1185,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
SerializerAttributesHolder holder = entry.getValue();
try {
Class cl = getCachedClass(name);
- DataSerializer ds = null;
+ DataSerializer ds;
if (holder.getEventId() != null) {
ds = register(cl, false, holder.getEventId(), holder.getProxyId());
} else {
@@ -1404,13 +1404,13 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
}
try {
invokeToData(o, out);
- } catch (IOException io) {
+ } catch (IOException | CancelException | ToDataException | GemFireRethrowable io) {
// Note: this is not a user code toData but one from our
// internal code since only GemFire product code implements DSFID
- throw io;
- } catch (CancelException | ToDataException | GemFireRethrowable ex) {
+
// Serializing a PDX can result in a cache closed exception. Just rethrow
- throw ex;
+
+ throw io;
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// If this ever returns, rethrow the error. We're poisoned
@@ -1726,7 +1726,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
final int size = readArrayLength(in);
if (size >= 0) {
for (int index = 0; index < size; ++index) {
- E element = DataSerializer.<E>readObject(in);
+ E element = DataSerializer.readObject(in);
c.add(element);
}
@@ -2582,7 +2582,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
}
}
- public static int readDSFIDHeader(final DataInput in) throws IOException, ClassNotFoundException {
+ public static int readDSFIDHeader(final DataInput in) throws IOException {
checkIn(in);
byte header = in.readByte();
if (header == DS_FIXED_ID_BYTE) {
@@ -2666,11 +2666,11 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
throws IOException, ClassNotFoundException {
boolean wouldReadSerialized = PdxInstanceImpl.getPdxReadSerialized();
if (!wouldReadSerialized) {
- return DataSerializer.<T>readObject(in);
+ return DataSerializer.readObject(in);
} else {
PdxInstanceImpl.setPdxReadSerialized(false);
try {
- return DataSerializer.<T>readObject(in);
+ return DataSerializer.readObject(in);
} finally {
PdxInstanceImpl.setPdxReadSerialized(true);
}
@@ -2878,7 +2878,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
}
private static Object readUserDataSerializable(final DataInput in, int classId)
- throws IOException, ClassNotFoundException {
+ throws IOException {
Instantiator instantiator = InternalInstantiator.getInstantiator(classId);
if (instantiator == null) {
logger.error(LogMarker.SERIALIZER,
@@ -3698,7 +3698,7 @@ public abstract class InternalDataSerializer extends DataSerializer implements D
synchronized (cacheAccessLock) {
Class<?> cachedClass = getExistingCachedClass(className);
if (cachedClass == null) {
- classCache.put(className, new WeakReference<Class<?>>(result));
+ classCache.put(className, new WeakReference<>(result));
} else {
result = cachedClass;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteTransportConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteTransportConfig.java b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteTransportConfig.java
index af3cb5d..1dc2fd1 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteTransportConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteTransportConfig.java
@@ -14,7 +14,21 @@
*/
package org.apache.geode.internal.admin.remote;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMBERSHIP_PORT_RANGE;
+import static org.apache.geode.distributed.ConfigurationProperties.TCP_PORT;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.Assert;
+import org.apache.geode.internal.admin.SSLConfig;
+import org.apache.geode.internal.admin.TransportConfig;
+import org.apache.geode.internal.i18n.LocalizedStrings;
import java.util.Collection;
import java.util.Collections;
@@ -24,13 +38,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.Assert;
-import org.apache.geode.internal.admin.SSLConfig;
-import org.apache.geode.internal.admin.TransportConfig;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.StringUtils;
-
/**
* Tranport config for RemoteGfManagerAgent.
*/
@@ -99,7 +106,7 @@ public class RemoteTransportConfig implements TransportConfig {
StringTokenizer stringTokenizer = new StringTokenizer(initialHosts, ",");
while (stringTokenizer.hasMoreTokens()) {
String locator = stringTokenizer.nextToken();
- if (!StringUtils.isEmpty(locator)) {
+ if (StringUtils.isNotEmpty(locator)) {
locators.add(new DistributionLocatorId(locator));
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
index 55e3542..37f2120 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
@@ -17,41 +17,40 @@ package org.apache.geode.internal.cache;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Stream;
-
import org.apache.commons.lang.ArrayUtils;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.UnmodifiableException;
import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.tcpserver.TcpClient;
+import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.ConfigSource;
import org.apache.geode.internal.DeployedJar;
import org.apache.geode.internal.JarDeployer;
import org.apache.geode.internal.admin.remote.DistributionLocatorId;
import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.process.ClusterConfigurationNotAvailableException;
import org.apache.geode.management.internal.configuration.domain.Configuration;
import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
import org.apache.geode.management.internal.configuration.messages.ConfigurationResponse;
+import org.apache.logging.log4j.Logger;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Stream;
public class ClusterConfigurationLoader {
@@ -121,7 +120,7 @@ public class ClusterConfigurationLoader {
requestedConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG);
if (clusterConfiguration != null) {
String cacheXmlContent = clusterConfiguration.getCacheXmlContent();
- if (!StringUtils.isBlank(cacheXmlContent)) {
+ if (StringUtils.isNotBlank(cacheXmlContent)) {
cacheXmlContentList.add(cacheXmlContent);
}
}
@@ -131,7 +130,7 @@ public class ClusterConfigurationLoader {
Configuration groupConfiguration = requestedConfiguration.get(group);
if (groupConfiguration != null) {
String cacheXmlContent = groupConfiguration.getCacheXmlContent();
- if (!StringUtils.isBlank(cacheXmlContent)) {
+ if (StringUtils.isNotBlank(cacheXmlContent)) {
cacheXmlContentList.add(cacheXmlContent);
}
}
@@ -230,7 +229,7 @@ public class ClusterConfigurationLoader {
String ipaddress = dlId.getBindAddress();
InetAddress locatorInetAddress = null;
- if (!StringUtils.isBlank(ipaddress)) {
+ if (StringUtils.isNotBlank(ipaddress)) {
locatorInetAddress = InetAddress.getByName(ipaddress);
} else {
locatorInetAddress = dlId.getHost();
@@ -265,7 +264,7 @@ public class ClusterConfigurationLoader {
private static List<String> getGroups(DistributionConfig config) {
String groupString = config.getGroups();
List<String> groups = new ArrayList<String>();
- if (!StringUtils.isBlank(groupString)) {
+ if (StringUtils.isNotBlank(groupString)) {
groups.addAll((Arrays.asList(groupString.split(","))));
}
return groups;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
index 185fde7..69684a3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
@@ -14,16 +14,8 @@
*/
package org.apache.geode.internal.cache;
-import static org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.function.Function;
-
-import org.apache.logging.log4j.Logger;
+import static org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE;
+import static org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_OLD_VALUE;
import org.apache.geode.CopyHelper;
import org.apache.geode.DataSerializer;
@@ -83,6 +75,14 @@ import org.apache.geode.internal.offheap.annotations.Unretained;
import org.apache.geode.internal.util.ArrayUtils;
import org.apache.geode.internal.util.BlobHelper;
import org.apache.geode.pdx.internal.PeerTypeRegistration;
+import org.apache.logging.log4j.Logger;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.function.Function;
/**
* Implementation of an entry event
[3/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 7a2d33d..b6c11c4 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -41,6 +41,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARC
import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
import static org.apache.geode.management.internal.cli.i18n.CliStrings.START_SERVER__PASSWORD;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.geode.GemFireException;
import org.apache.geode.SystemFailure;
import org.apache.geode.cache.server.CacheServer;
@@ -188,62 +189,46 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startLocator(
- @CliOption(key = CliStrings.START_LOCATOR__MEMBER_NAME, mandatory = false,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+ @CliOption(key = CliStrings.START_LOCATOR__MEMBER_NAME,
help = CliStrings.START_LOCATOR__MEMBER_NAME__HELP) String memberName,
@CliOption(key = CliStrings.START_LOCATOR__BIND_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__BIND_ADDRESS__HELP) final String bindAddress,
@CliOption(key = CliStrings.START_LOCATOR__CLASSPATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__CLASSPATH__HELP) final String classpath,
@CliOption(key = CliStrings.START_LOCATOR__FORCE, unspecifiedDefaultValue = "false",
specifiedDefaultValue = "true",
help = CliStrings.START_LOCATOR__FORCE__HELP) final Boolean force,
@CliOption(key = CliStrings.START_LOCATOR__GROUP, optionContext = ConverterHint.MEMBERGROUP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__GROUP__HELP) final String group,
@CliOption(key = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS__HELP) final String hostnameForClients,
@CliOption(key = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH,
specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
help = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH__HELP) final Boolean includeSystemClasspath,
@CliOption(key = CliStrings.START_LOCATOR__LOCATORS,
optionContext = ConverterHint.LOCATOR_DISCOVERY_CONFIG,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__LOCATORS__HELP) final String locators,
@CliOption(key = CliStrings.START_LOCATOR__LOG_LEVEL, optionContext = ConverterHint.LOG_LEVEL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__LOG_LEVEL__HELP) final String logLevel,
@CliOption(key = CliStrings.START_LOCATOR__MCAST_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__MCAST_ADDRESS__HELP) final String mcastBindAddress,
@CliOption(key = CliStrings.START_LOCATOR__MCAST_PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__MCAST_PORT__HELP) final Integer mcastPort,
@CliOption(key = CliStrings.START_LOCATOR__PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__PORT__HELP) final Integer port,
@CliOption(key = CliStrings.START_LOCATOR__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__DIR__HELP) String workingDirectory,
@CliOption(key = CliStrings.START_LOCATOR__PROPERTIES,
optionContext = ConverterHint.FILE_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__PROPERTIES__HELP) String gemfirePropertiesPathname,
@CliOption(key = CliStrings.START_LOCATOR__SECURITY_PROPERTIES,
optionContext = ConverterHint.FILE_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__SECURITY_PROPERTIES__HELP) String gemfireSecurityPropertiesPathname,
@CliOption(key = CliStrings.START_LOCATOR__INITIALHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__INITIALHEAP__HELP) final String initialHeap,
@CliOption(key = CliStrings.START_LOCATOR__MAXHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__MAXHEAP__HELP) final String maxHeap,
@CliOption(key = CliStrings.START_LOCATOR__J,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__J__HELP) final String[] jvmArgsOpts,
@CliOption(key = CliStrings.START_LOCATOR__CONNECT, unspecifiedDefaultValue = "true",
specifiedDefaultValue = "true",
@@ -257,10 +242,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliOption(key = CliStrings.START_LOCATOR__CLUSTER__CONFIG__DIR, unspecifiedDefaultValue = "",
help = CliStrings.START_LOCATOR__CLUSTER__CONFIG__DIR__HELP) final String clusterConfigDir,
@CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT__HELP) final Integer httpServicePort,
@CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS__HELP) final String httpServiceBindAddress) {
try {
if (StringUtils.isBlank(memberName)) {
@@ -272,17 +255,17 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
gemfirePropertiesPathname = CliUtil.resolvePathname(gemfirePropertiesPathname);
- if (!StringUtils.isBlank(gemfirePropertiesPathname)
+ if (StringUtils.isNotBlank(gemfirePropertiesPathname)
&& !IOUtils.isExistingPathname(gemfirePropertiesPathname)) {
return ResultBuilder.createUserErrorResult(
- CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE,
- StringUtils.EMPTY_STRING, gemfirePropertiesPathname));
+ CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY,
+ gemfirePropertiesPathname));
}
gemfireSecurityPropertiesPathname =
CliUtil.resolvePathname(gemfireSecurityPropertiesPathname);
- if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname)
+ if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname)
&& !IOUtils.isExistingPathname(gemfireSecurityPropertiesPathname)) {
return ResultBuilder.createUserErrorResult(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
@@ -295,42 +278,41 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(GROUPS, StringUtils.valueOf(group, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(LOCATORS,
- StringUtils.valueOf(locators, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(LOG_LEVEL,
- StringUtils.valueOf(logLevel, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(MCAST_ADDRESS,
- StringUtils.valueOf(mcastBindAddress, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(MCAST_PORT,
- StringUtils.valueOf(mcastPort, StringUtils.EMPTY_STRING));
+ gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group));
+ gemfireProperties.setProperty(LOCATORS, StringUtils.defaultString(locators));
+ gemfireProperties.setProperty(LOG_LEVEL, StringUtils.defaultString(logLevel));
+ gemfireProperties.setProperty(MCAST_ADDRESS, StringUtils.defaultString(mcastBindAddress));
+ gemfireProperties.setProperty(MCAST_PORT, StringUtils.defaultString(mcastPort));
gemfireProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION,
- StringUtils.valueOf(enableSharedConfiguration, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(enableSharedConfiguration));
gemfireProperties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR,
- StringUtils.valueOf(loadSharedConfigurationFromDirectory, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(loadSharedConfigurationFromDirectory));
gemfireProperties.setProperty(CLUSTER_CONFIGURATION_DIR,
- StringUtils.valueOf(clusterConfigDir, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(HTTP_SERVICE_PORT,
- StringUtils.valueOf(httpServicePort, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(clusterConfigDir));
+ gemfireProperties.setProperty(HTTP_SERVICE_PORT, StringUtils.defaultString(httpServicePort));
gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,
- StringUtils.valueOf(httpServiceBindAddress, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(httpServiceBindAddress));
// read the OSProcess enable redirect system property here -- TODO: replace with new GFSH
// argument
final boolean redirectOutput =
Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY);
- LocatorLauncher locatorLauncher =
- new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force)
- .setHostnameForClients(hostnameForClients).setMemberName(memberName).setPort(port)
- .setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory).build();
+ LocatorLauncher.Builder locatorLauncherBuilder =
+ new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force).setPort(port)
+ .setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory);
+ if (hostnameForClients != null) {
+ locatorLauncherBuilder.setHostnameForClients(hostnameForClients);
+ }
+ if (memberName != null) {
+ locatorLauncherBuilder.setMemberName(memberName);
+ }
+ LocatorLauncher locatorLauncher = locatorLauncherBuilder.build();
String[] locatorCommandLine = createStartLocatorCommandLine(locatorLauncher,
gemfirePropertiesPathname, gemfireSecurityPropertiesPathname, gemfireProperties,
classpath, includeSystemClasspath, jvmArgsOpts, initialHeap, maxHeap);
- // getGfsh().logInfo(StringUtils.concat(locatorCommandLine, " "), null);
-
final Process locatorProcess = new ProcessBuilder(locatorCommandLine)
.directory(new File(locatorLauncher.getWorkingDirectory())).start();
@@ -502,7 +484,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
commandLine.add(LocatorLauncher.class.getName());
commandLine.add(LocatorLauncher.Command.START.getName());
- if (!StringUtils.isBlank(launcher.getMemberName())) {
+ if (StringUtils.isNotBlank(launcher.getMemberName())) {
commandLine.add(launcher.getMemberName());
}
@@ -518,7 +500,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
commandLine.add("--force");
}
- if (!StringUtils.isBlank(launcher.getHostnameForClients())) {
+ if (StringUtils.isNotBlank(launcher.getHostnameForClients())) {
commandLine.add("--hostname-for-clients=" + launcher.getHostnameForClients());
}
@@ -615,7 +597,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
jmxManagerSslEnabled, infoResultData);
}
- if (!StringUtils.isBlank(responseFailureMessage)) {
+ if (StringUtils.isNotBlank(responseFailureMessage)) {
infoResultData.addLine("\n");
infoResultData.addLine(responseFailureMessage);
}
@@ -639,7 +621,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
message.append("Authentication");
}
if (jmxManagerSslEnabled) {
- message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY_STRING)
+ message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY)
.append("SSL configuration");
}
if (jmxManagerAuthEnabled || jmxManagerSslEnabled) {
@@ -657,7 +639,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
private Map<String, String> loadConfigurationProperties(
final String configurationPropertiesPathname, Map<String, String> configurationProperties) {
configurationProperties =
- (configurationProperties != null ? configurationProperties : new HashMap<String, String>());
+ (configurationProperties != null ? configurationProperties : new HashMap<>());
if (IOUtils.isExistingPathname(configurationPropertiesPathname)) {
try {
@@ -763,22 +745,17 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
public Result statusLocator(
@CliOption(key = CliStrings.STATUS_LOCATOR__MEMBER,
optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_LOCATOR__MEMBER__HELP) final String member,
@CliOption(key = CliStrings.STATUS_LOCATOR__HOST,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_LOCATOR__HOST__HELP) final String locatorHost,
@CliOption(key = CliStrings.STATUS_LOCATOR__PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_LOCATOR__PORT__HELP) final Integer locatorPort,
@CliOption(key = CliStrings.STATUS_LOCATOR__PID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_LOCATOR__PID__HELP) final Integer pid,
@CliOption(key = CliStrings.STATUS_LOCATOR__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_LOCATOR__DIR__HELP) final String workingDirectory) {
try {
- if (!StringUtils.isBlank(member)) {
+ if (StringUtils.isNotBlank(member)) {
if (isConnectedAndReady()) {
final MemberMXBean locatorProxy = getMemberMXBean(member);
@@ -802,9 +779,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
final LocatorState state = locatorLauncher.status();
return createStatusLocatorResult(state);
}
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
return ResultBuilder.createUserErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -824,18 +799,15 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
public Result stopLocator(
@CliOption(key = CliStrings.STOP_LOCATOR__MEMBER,
optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_LOCATOR__MEMBER__HELP) final String member,
@CliOption(key = CliStrings.STOP_LOCATOR__PID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_LOCATOR__PID__HELP) final Integer pid,
@CliOption(key = CliStrings.STOP_LOCATOR__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_LOCATOR__DIR__HELP) final String workingDirectory) {
LocatorState locatorState;
try {
- if (!StringUtils.isBlank(member)) {
+ if (StringUtils.isNotBlank(member)) {
if (isConnectedAndReady()) {
final MemberMXBean locatorProxy = getMemberMXBean(member);
@@ -887,13 +859,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
}
- return ResultBuilder.createInfoResult(StringUtils.EMPTY_STRING);
+ return ResultBuilder.createInfoResult(StringUtils.EMPTY);
} else {
return ResultBuilder.createUserErrorResult(locatorState.toString());
}
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
return ResultBuilder.createUserErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -917,7 +887,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
if (StringUtils.isBlank(gemfireProperties.getProperty(LOCATORS))) {
String currentLocators = getCurrentLocators();
- if (!StringUtils.isBlank(currentLocators)) {
+ if (StringUtils.isNotBlank(currentLocators)) {
commandLine.add("-D".concat(ProcessLauncherContext.OVERRIDDEN_DEFAULTS_PREFIX)
.concat(LOCATORS).concat("=").concat(currentLocators));
}
@@ -934,14 +904,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected void addGemFirePropertyFile(final List<String> commandLine,
final String gemfirePropertiesPathname) {
- if (!StringUtils.isBlank(gemfirePropertiesPathname)) {
+ if (StringUtils.isNotBlank(gemfirePropertiesPathname)) {
commandLine.add("-DgemfirePropertyFile=" + gemfirePropertiesPathname);
}
}
protected void addGemFireSecurityPropertyFile(final List<String> commandLine,
final String gemfireSecurityPropertiesPathname) {
- if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname)) {
+ if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname)) {
commandLine.add("-DgemfireSecurityPropertyFile=" + gemfireSecurityPropertiesPathname);
}
}
@@ -951,7 +921,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
for (final Object property : gemfireProperties.keySet()) {
final String propertyName = property.toString();
final String propertyValue = gemfireProperties.getProperty(propertyName);
- if (!StringUtils.isBlank(propertyValue)) {
+ if (StringUtils.isNotBlank(propertyValue)) {
commandLine.add(
"-D" + DistributionConfig.GEMFIRE_PREFIX + "" + propertyName + "=" + propertyValue);
}
@@ -959,7 +929,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
protected void addInitialHeap(final List<String> commandLine, final String initialHeap) {
- if (!StringUtils.isBlank(initialHeap)) {
+ if (StringUtils.isNotBlank(initialHeap)) {
commandLine.add("-Xms" + initialHeap);
}
}
@@ -997,7 +967,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
protected void addMaxHeap(final List<String> commandLine, final String maxHeap) {
- if (!StringUtils.isBlank(maxHeap)) {
+ if (StringUtils.isNotBlank(maxHeap)) {
commandLine.add("-Xmx" + maxHeap);
commandLine.add("-XX:+UseConcMarkSweepGC");
commandLine.add("-XX:CMSInitiatingOccupancyFraction=" + CMS_INITIAL_OCCUPANCY_FRACTION);
@@ -1053,8 +1023,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
try {
fileReader = new BufferedReader(new FileReader(pidFile));
return Integer.parseInt(fileReader.readLine());
- } catch (IOException ignore) {
- } catch (NumberFormatException ignore) {
+ } catch (IOException | NumberFormatException ignore) {
} finally {
IOUtils.close(fileReader);
}
@@ -1094,7 +1063,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected String getClasspath(final String userClasspath) {
String classpath = getSystemClasspath();
- if (!StringUtils.isBlank(userClasspath)) {
+ if (StringUtils.isNotBlank(userClasspath)) {
classpath += (File.pathSeparator + userClasspath);
}
@@ -1124,9 +1093,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
String toClasspath(final boolean includeSystemClasspath, String[] jarFilePathnames,
String... userClasspaths) {
// gemfire jar must absolutely be the first JAR file on the CLASSPATH!!!
- String classpath = getGemFireJarPath();
+ StringBuilder classpath = new StringBuilder(getGemFireJarPath());
- userClasspaths = (userClasspaths != null ? userClasspaths : StringUtils.EMPTY_STRING_ARRAY);
+ userClasspaths = (userClasspaths != null ? userClasspaths : ArrayUtils.EMPTY_STRING_ARRAY);
// Then, include user-specified classes on CLASSPATH to enable the user to override GemFire JAR
// dependencies
@@ -1137,30 +1106,30 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
// System CLASSPATH environment variable setting, which is consistent with the Java platform
// behavior...
for (String userClasspath : userClasspaths) {
- if (!StringUtils.isBlank(userClasspath)) {
- classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
- classpath += userClasspath;
+ if (StringUtils.isNotBlank(userClasspath)) {
+ classpath.append((classpath.length() == 0) ? StringUtils.EMPTY : File.pathSeparator);
+ classpath.append(userClasspath);
}
}
// Now, include any System-specified CLASSPATH environment variable setting...
if (includeSystemClasspath) {
- classpath += File.pathSeparator;
- classpath += getSystemClasspath();
+ classpath.append(File.pathSeparator);
+ classpath.append(getSystemClasspath());
}
jarFilePathnames =
- (jarFilePathnames != null ? jarFilePathnames : StringUtils.EMPTY_STRING_ARRAY);
+ (jarFilePathnames != null ? jarFilePathnames : ArrayUtils.EMPTY_STRING_ARRAY);
// And finally, include all GemFire dependencies on the CLASSPATH...
for (String jarFilePathname : jarFilePathnames) {
- if (!StringUtils.isBlank(jarFilePathname)) {
- classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
- classpath += jarFilePathname;
+ if (StringUtils.isNotBlank(jarFilePathname)) {
+ classpath.append((classpath.length() == 0) ? StringUtils.EMPTY : File.pathSeparator);
+ classpath.append(jarFilePathname);
}
}
- return classpath;
+ return classpath.toString();
}
protected String getGemFireJarPath() {
@@ -1194,7 +1163,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected String getLocatorId(final String host, final Integer port) {
final String locatorHost = (host != null ? host : getLocalHost());
final String locatorPort =
- StringUtils.valueOf(port, String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT));
+ StringUtils.defaultString(port, String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT));
return locatorHost.concat("[").concat(locatorPort).concat("]");
}
@@ -1238,7 +1207,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
try {
String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX;
- objectNamePattern += (StringUtils.isBlank(serviceName) ? StringUtils.EMPTY_STRING
+ objectNamePattern += (StringUtils.isBlank(serviceName) ? StringUtils.EMPTY
: "service=" + serviceName + StringUtils.COMMA_DELIMITER);
objectNamePattern += "type=Member,*";
@@ -1266,7 +1235,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected String getServerId(final String host, final Integer port) {
String serverHost = (host != null ? host : getLocalHost());
- String serverPort = StringUtils.valueOf(port, String.valueOf(CacheServer.DEFAULT_PORT));
+ String serverPort = StringUtils.defaultString(port, String.valueOf(CacheServer.DEFAULT_PORT));
return serverHost.concat("[").concat(serverPort).concat("]");
}
@@ -1287,31 +1256,24 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startServer(
- @CliOption(key = CliStrings.START_SERVER__NAME, mandatory = false,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+ @CliOption(key = CliStrings.START_SERVER__NAME,
help = CliStrings.START_SERVER__NAME__HELP) String memberName,
@CliOption(key = CliStrings.START_SERVER__ASSIGN_BUCKETS, unspecifiedDefaultValue = "false",
specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__ASSIGN_BUCKETS__HELP) final Boolean assignBuckets,
@CliOption(key = CliStrings.START_SERVER__BIND_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__BIND_ADDRESS__HELP) final String bindAddress,
@CliOption(key = CliStrings.START_SERVER__CACHE_XML_FILE,
optionContext = ConverterHint.FILE_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__CACHE_XML_FILE__HELP) String cacheXmlPathname,
@CliOption(key = CliStrings.START_SERVER__CLASSPATH,
/* optionContext = ConverterHint.FILE_PATH, // there's an issue with TAB here */
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__CLASSPATH__HELP) final String classpath,
@CliOption(key = CliStrings.START_SERVER__CRITICAL__HEAP__PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__CRITICAL__HEAP__HELP) final Float criticalHeapPercentage,
@CliOption(key = CliStrings.START_SERVER__CRITICAL_OFF_HEAP_PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__CRITICAL_OFF_HEAP__HELP) final Float criticalOffHeapPercentage,
@CliOption(key = CliStrings.START_SERVER__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__DIR__HELP) String workingDirectory,
@CliOption(key = CliStrings.START_SERVER__DISABLE_DEFAULT_SERVER,
unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
@@ -1320,98 +1282,70 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__DISABLE_EXIT_WHEN_OUT_OF_MEMORY_HELP) final Boolean disableExitWhenOutOfMemory,
@CliOption(key = CliStrings.START_SERVER__ENABLE_TIME_STATISTICS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__ENABLE_TIME_STATISTICS__HELP) final Boolean enableTimeStatistics,
@CliOption(key = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE__HELP) final Float evictionHeapPercentage,
@CliOption(key = CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE__HELP) final Float evictionOffHeapPercentage,
@CliOption(key = CliStrings.START_SERVER__FORCE, unspecifiedDefaultValue = "false",
specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__FORCE__HELP) final Boolean force,
@CliOption(key = CliStrings.START_SERVER__GROUP, optionContext = ConverterHint.MEMBERGROUP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__GROUP__HELP) final String group,
@CliOption(key = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS__HELP) final String hostNameForClients,
@CliOption(key = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH,
specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
help = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH__HELP) final Boolean includeSystemClasspath,
@CliOption(key = CliStrings.START_SERVER__INITIAL_HEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__INITIAL_HEAP__HELP) final String initialHeap,
@CliOption(key = CliStrings.START_SERVER__J,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__J__HELP) final String[] jvmArgsOpts,
@CliOption(key = CliStrings.START_SERVER__LOCATORS,
optionContext = ConverterHint.LOCATOR_DISCOVERY_CONFIG,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__LOCATORS__HELP) final String locators,
@CliOption(key = CliStrings.START_SERVER__LOCATOR_WAIT_TIME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__LOCATOR_WAIT_TIME_HELP) final Integer locatorWaitTime,
- @CliOption(key = CliStrings.START_SERVER__LOCK_MEMORY,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- specifiedDefaultValue = "true",
+ @CliOption(key = CliStrings.START_SERVER__LOCK_MEMORY, specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__LOCK_MEMORY__HELP) final Boolean lockMemory,
@CliOption(key = CliStrings.START_SERVER__LOG_LEVEL, optionContext = ConverterHint.LOG_LEVEL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__LOG_LEVEL__HELP) final String logLevel,
@CliOption(key = CliStrings.START_SERVER__MAX__CONNECTIONS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MAX__CONNECTIONS__HELP) final Integer maxConnections,
@CliOption(key = CliStrings.START_SERVER__MAXHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MAXHEAP__HELP) final String maxHeap,
@CliOption(key = CliStrings.START_SERVER__MAX__MESSAGE__COUNT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MAX__MESSAGE__COUNT__HELP) final Integer maxMessageCount,
@CliOption(key = CliStrings.START_SERVER__MAX__THREADS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MAX__THREADS__HELP) final Integer maxThreads,
@CliOption(key = CliStrings.START_SERVER__MCAST_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MCAST_ADDRESS__HELP) final String mcastBindAddress,
@CliOption(key = CliStrings.START_SERVER__MCAST_PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MCAST_PORT__HELP) final Integer mcastPort,
@CliOption(key = CliStrings.START_SERVER__MEMCACHED_PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MEMCACHED_PORT__HELP) final Integer memcachedPort,
@CliOption(key = CliStrings.START_SERVER__MEMCACHED_PROTOCOL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MEMCACHED_PROTOCOL__HELP) final String memcachedProtocol,
@CliOption(key = CliStrings.START_SERVER__MEMCACHED_BIND_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MEMCACHED_BIND_ADDRESS__HELP) final String memcachedBindAddress,
@CliOption(key = CliStrings.START_SERVER__REDIS_PORT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__REDIS_PORT__HELP) final Integer redisPort,
@CliOption(key = CliStrings.START_SERVER__REDIS_BIND_ADDRESS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__REDIS_BIND_ADDRESS__HELP) final String redisBindAddress,
@CliOption(key = CliStrings.START_SERVER__REDIS_PASSWORD,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__REDIS_PASSWORD__HELP) final String redisPassword,
@CliOption(key = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE__HELP) final Integer messageTimeToLive,
@CliOption(key = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE__HELP) final String offHeapMemorySize,
@CliOption(key = CliStrings.START_SERVER__PROPERTIES, optionContext = ConverterHint.FILE_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__PROPERTIES__HELP) String gemfirePropertiesPathname,
@CliOption(key = CliStrings.START_SERVER__REBALANCE, unspecifiedDefaultValue = "false",
specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__REBALANCE__HELP) final Boolean rebalance,
@CliOption(key = CliStrings.START_SERVER__SECURITY_PROPERTIES,
optionContext = ConverterHint.FILE_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__SECURITY_PROPERTIES__HELP) String gemfireSecurityPropertiesPathname,
@CliOption(key = CliStrings.START_SERVER__SERVER_BIND_ADDRESS,
unspecifiedDefaultValue = CacheServer.DEFAULT_BIND_ADDRESS,
@@ -1420,13 +1354,10 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
unspecifiedDefaultValue = ("" + CacheServer.DEFAULT_PORT),
help = CliStrings.START_SERVER__SERVER_PORT__HELP) final Integer serverPort,
@CliOption(key = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE__HELP) final Integer socketBufferSize,
@CliOption(key = CliStrings.START_SERVER__SPRING_XML_LOCATION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__SPRING_XML_LOCATION_HELP) final String springXmlLocation,
@CliOption(key = CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE__HELP) final String statisticsArchivePathname,
@CliOption(key = CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION,
unspecifiedDefaultValue = "true", specifiedDefaultValue = "true",
@@ -1452,7 +1383,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
// prompt for password is username is specified in the command
- if (!StringUtils.isBlank(userName)) {
+ if (StringUtils.isNotBlank(userName)) {
if (StringUtils.isBlank(passwordToUse)) {
passwordToUse = getGfsh().readPassword(START_SERVER__PASSWORD + ": ");
}
@@ -1466,24 +1397,25 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
cacheXmlPathname = CliUtil.resolvePathname(cacheXmlPathname);
- if (!StringUtils.isBlank(cacheXmlPathname) && !IOUtils.isExistingPathname(cacheXmlPathname)) {
+ if (StringUtils.isNotBlank(cacheXmlPathname)
+ && !IOUtils.isExistingPathname(cacheXmlPathname)) {
return ResultBuilder.createUserErrorResult(
CliStrings.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname));
}
gemfirePropertiesPathname = CliUtil.resolvePathname(gemfirePropertiesPathname);
- if (!StringUtils.isBlank(gemfirePropertiesPathname)
+ if (StringUtils.isNotBlank(gemfirePropertiesPathname)
&& !IOUtils.isExistingPathname(gemfirePropertiesPathname)) {
return ResultBuilder.createUserErrorResult(
- CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE,
- StringUtils.EMPTY_STRING, gemfirePropertiesPathname));
+ CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY,
+ gemfirePropertiesPathname));
}
gemfireSecurityPropertiesPathname =
CliUtil.resolvePathname(gemfireSecurityPropertiesPathname);
- if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname)
+ if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname)
&& !IOUtils.isExistingPathname(gemfireSecurityPropertiesPathname)) {
return ResultBuilder.createUserErrorResult(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
@@ -1496,52 +1428,39 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(BIND_ADDRESS,
- StringUtils.valueOf(bindAddress, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(CACHE_XML_FILE,
- StringUtils.valueOf(cacheXmlPathname, StringUtils.EMPTY_STRING));
+ gemfireProperties.setProperty(BIND_ADDRESS, StringUtils.defaultString(bindAddress));
+ gemfireProperties.setProperty(CACHE_XML_FILE, StringUtils.defaultString(cacheXmlPathname));
gemfireProperties.setProperty(ENABLE_TIME_STATISTICS,
- StringUtils.valueOf(enableTimeStatistics, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(GROUPS, StringUtils.valueOf(group, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(LOCATORS,
- StringUtils.valueOf(locators, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(LOCATOR_WAIT_TIME,
- StringUtils.valueOf(locatorWaitTime, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(LOG_LEVEL,
- StringUtils.valueOf(logLevel, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(MCAST_ADDRESS,
- StringUtils.valueOf(mcastBindAddress, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(MCAST_PORT,
- StringUtils.valueOf(mcastPort, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(MEMCACHED_PORT,
- StringUtils.valueOf(memcachedPort, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(enableTimeStatistics));
+ gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group));
+ gemfireProperties.setProperty(LOCATORS, StringUtils.defaultString(locators));
+ gemfireProperties.setProperty(LOCATOR_WAIT_TIME, StringUtils.defaultString(locatorWaitTime));
+ gemfireProperties.setProperty(LOG_LEVEL, StringUtils.defaultString(logLevel));
+ gemfireProperties.setProperty(MCAST_ADDRESS, StringUtils.defaultString(mcastBindAddress));
+ gemfireProperties.setProperty(MCAST_PORT, StringUtils.defaultString(mcastPort));
+ gemfireProperties.setProperty(MEMCACHED_PORT, StringUtils.defaultString(memcachedPort));
gemfireProperties.setProperty(MEMCACHED_PROTOCOL,
- StringUtils.valueOf(memcachedProtocol, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(memcachedProtocol));
gemfireProperties.setProperty(MEMCACHED_BIND_ADDRESS,
- StringUtils.valueOf(memcachedBindAddress, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(REDIS_PORT,
- StringUtils.valueOf(redisPort, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(memcachedBindAddress));
+ gemfireProperties.setProperty(REDIS_PORT, StringUtils.defaultString(redisPort));
gemfireProperties.setProperty(REDIS_BIND_ADDRESS,
- StringUtils.valueOf(redisBindAddress, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(REDIS_PASSWORD,
- StringUtils.valueOf(redisPassword, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(redisBindAddress));
+ gemfireProperties.setProperty(REDIS_PASSWORD, StringUtils.defaultString(redisPassword));
gemfireProperties.setProperty(STATISTIC_ARCHIVE_FILE,
- StringUtils.valueOf(statisticsArchivePathname, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(statisticsArchivePathname));
gemfireProperties.setProperty(USE_CLUSTER_CONFIGURATION,
- StringUtils.valueOf(requestSharedConfiguration, Boolean.TRUE.toString()));
- gemfireProperties.setProperty(LOCK_MEMORY,
- StringUtils.valueOf(lockMemory, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(requestSharedConfiguration, Boolean.TRUE.toString()));
+ gemfireProperties.setProperty(LOCK_MEMORY, StringUtils.defaultString(lockMemory));
gemfireProperties.setProperty(OFF_HEAP_MEMORY_SIZE,
- StringUtils.valueOf(offHeapMemorySize, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(START_DEV_REST_API,
- StringUtils.valueOf(startRestApi, StringUtils.EMPTY_STRING));
- gemfireProperties.setProperty(HTTP_SERVICE_PORT,
- StringUtils.valueOf(httpServicePort, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(offHeapMemorySize));
+ gemfireProperties.setProperty(START_DEV_REST_API, StringUtils.defaultString(startRestApi));
+ gemfireProperties.setProperty(HTTP_SERVICE_PORT, StringUtils.defaultString(httpServicePort));
gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,
- StringUtils.valueOf(httpServiceBindAddress, StringUtils.EMPTY_STRING));
+ StringUtils.defaultString(httpServiceBindAddress));
// if username is specified in the command line, it will overwrite what's set in the
// properties file
- if (!StringUtils.isBlank(userName)) {
+ if (StringUtils.isNotBlank(userName)) {
gemfireProperties.setProperty(ResourceConstants.USER_NAME, userName);
gemfireProperties.setProperty(ResourceConstants.PASSWORD, passwordToUse);
}
@@ -1552,9 +1471,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
final boolean redirectOutput =
Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY);
- ServerLauncher serverLauncher = new ServerLauncher.Builder().setAssignBuckets(assignBuckets)
- .setDisableDefaultServer(disableDefaultServer).setForce(force).setMemberName(memberName)
- .setRebalance(rebalance).setRedirectOutput(redirectOutput)
+ ServerLauncher.Builder serverLauncherBuilder = new ServerLauncher.Builder()
+ .setAssignBuckets(assignBuckets).setDisableDefaultServer(disableDefaultServer)
+ .setForce(force).setRebalance(rebalance).setRedirectOutput(redirectOutput)
.setServerBindAddress(serverBindAddress).setServerPort(serverPort)
.setSpringXmlLocation(springXmlLocation).setWorkingDirectory(workingDirectory)
.setCriticalHeapPercentage(criticalHeapPercentage)
@@ -1562,8 +1481,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
.setCriticalOffHeapPercentage(criticalOffHeapPercentage)
.setEvictionOffHeapPercentage(evictionOffHeapPercentage).setMaxConnections(maxConnections)
.setMaxMessageCount(maxMessageCount).setMaxThreads(maxThreads)
- .setMessageTimeToLive(messageTimeToLive).setSocketBufferSize(socketBufferSize)
- .setHostNameForClients(hostNameForClients).build();
+ .setMessageTimeToLive(messageTimeToLive).setSocketBufferSize(socketBufferSize);
+ if (hostNameForClients != null) {
+ serverLauncherBuilder.setHostNameForClients(hostNameForClients);
+ }
+ if (memberName != null) {
+ serverLauncherBuilder.setMemberName(memberName);
+ }
+ ServerLauncher serverLauncher = serverLauncherBuilder.build();
String[] serverCommandLine = createStartServerCommandLine(serverLauncher,
gemfirePropertiesPathname, gemfireSecurityPropertiesPathname, gemfireProperties,
@@ -1571,7 +1496,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
maxHeap);
if (getGfsh().getDebug()) {
- getGfsh().logInfo(StringUtils.concat(serverCommandLine, " "), null);
+ getGfsh().logInfo(StringUtils.join(serverCommandLine, StringUtils.SPACE), null);
}
Process serverProcess = new ProcessBuilder(serverCommandLine)
@@ -1722,7 +1647,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
commandLine.add(ServerLauncher.class.getName());
commandLine.add(ServerLauncher.Command.START.getName());
- if (!StringUtils.isBlank(launcher.getMemberName())) {
+ if (StringUtils.isNotBlank(launcher.getMemberName())) {
commandLine.add(launcher.getMemberName());
}
@@ -1847,16 +1772,13 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result statusServer(
@CliOption(key = CliStrings.STATUS_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_SERVER__MEMBER__HELP) final String member,
@CliOption(key = CliStrings.STATUS_SERVER__PID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_SERVER__PID__HELP) final Integer pid,
@CliOption(key = CliStrings.STATUS_SERVER__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STATUS_SERVER__DIR__HELP) final String workingDirectory) {
try {
- if (!StringUtils.isBlank(member)) {
+ if (StringUtils.isNotBlank(member)) {
if (isConnectedAndReady()) {
final MemberMXBean serverProxy = getMemberMXBean(member);
@@ -1886,9 +1808,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
return ResultBuilder.createInfoResult(status.toString());
}
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
return ResultBuilder.createUserErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -1905,18 +1825,15 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result stopServer(
@CliOption(key = CliStrings.STOP_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_SERVER__MEMBER__HELP) final String member,
@CliOption(key = CliStrings.STOP_SERVER__PID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_SERVER__PID__HELP) final Integer pid,
@CliOption(key = CliStrings.STOP_SERVER__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.STOP_SERVER__DIR__HELP) final String workingDirectory) {
ServerState serverState;
try {
- if (!StringUtils.isBlank(member)) {
+ if (StringUtils.isNotBlank(member)) {
if (isConnectedAndReady()) {
final MemberMXBean serverProxy = getMemberMXBean(member);
@@ -1963,13 +1880,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
}
- return ResultBuilder.createInfoResult(StringUtils.EMPTY_STRING);
+ return ResultBuilder.createInfoResult(StringUtils.EMPTY);
} else {
return ResultBuilder.createUserErrorResult(serverState.toString());
}
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
return ResultBuilder.createUserErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -1988,10 +1903,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
// CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startManager(
@CliOption(key = CliStrings.START_MANAGER__MEMBERNAME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__MEMBERNAME__HELP) String memberName,
@CliOption(key = CliStrings.START_MANAGER__DIR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__DIR__HELP) String dir,
@CliOption(key = CliStrings.START_MANAGER__PORT, unspecifiedDefaultValue = "1099",
help = CliStrings.START_MANAGER__PORT__HELP) int cacheServerPort,
@@ -1999,19 +1912,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
unspecifiedDefaultValue = "localhost",
help = CliStrings.START_MANAGER__BIND_ADDRESS__HELP) String cacheServerHost,
@CliOption(key = CliStrings.START_MANAGER__CLASSPATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__CLASSPATH__HELP) String classpath,
@CliOption(key = CliStrings.START_MANAGER__MAXHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__MAXHEAP__HELP) String maxHeap,
@CliOption(key = CliStrings.START_MANAGER__INITIALHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__INITIALHEAP__HELP) String initialHeap,
@CliOption(key = CliStrings.START_MANAGER__J,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__J__HELP) Map<String, String> systepProps,
@CliOption(key = CliStrings.START_MANAGER__GEODEPROPS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_MANAGER__GEODEPROPS__HELP) Map<String, String> gemfireProps) {
return ResultBuilder.createInfoResult("Not-implemented");
}
@@ -2026,13 +1934,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
unspecifiedDefaultValue = "false",
help = CliStrings.START_JCONSOLE__NOTILE__HELP) final boolean notile,
@CliOption(key = CliStrings.START_JCONSOLE__PLUGINPATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_JCONSOLE__PLUGINPATH__HELP) final String pluginpath,
@CliOption(key = CliStrings.START_JCONSOLE__VERSION, specifiedDefaultValue = "true",
unspecifiedDefaultValue = "false",
help = CliStrings.START_JCONSOLE__VERSION__HELP) final boolean version,
@CliOption(key = CliStrings.START_JCONSOLE__J,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_JCONSOLE__J__HELP) final List<String> jvmArgs) {
try {
String[] jconsoleCommandLine =
@@ -2064,18 +1970,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
String jconsoleProcessOutput = waitAndCaptureProcessStandardErrorStream(jconsoleProcess);
- if (!StringUtils.isBlank(jconsoleProcessOutput)) {
+ if (StringUtils.isNotBlank(jconsoleProcessOutput)) {
message.append(StringUtils.LINE_SEPARATOR);
message.append(jconsoleProcessOutput);
}
}
return ResultBuilder.createInfoResult(message.toString());
- } catch (GemFireException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
return ResultBuilder.createShellClientErrorResult(e.getMessage());
} catch (IOException e) {
return ResultBuilder
@@ -2106,7 +2008,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
commandLine.add("-notile");
}
- if (!StringUtils.isBlank(pluginpath)) {
+ if (StringUtils.isNotBlank(pluginpath)) {
commandLine.add("-pluginpath " + pluginpath);
}
@@ -2118,7 +2020,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
String jmxServiceUrl = getJmxServiceUrlAsString(member);
- if (!StringUtils.isBlank(jmxServiceUrl)) {
+ if (StringUtils.isNotBlank(jmxServiceUrl)) {
commandLine.add(jmxServiceUrl);
}
}
@@ -2166,20 +2068,18 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
protected static String getExecutableSuffix() {
- return SystemUtils.isWindows() ? ".exe" : StringUtils.EMPTY_STRING;
+ return SystemUtils.isWindows() ? ".exe" : StringUtils.EMPTY;
}
protected String getJmxServiceUrlAsString(final String member) {
- if (!StringUtils.isBlank(member)) {
+ if (StringUtils.isNotBlank(member)) {
ConnectionEndpointConverter converter = new ConnectionEndpointConverter();
try {
ConnectionEndpoint connectionEndpoint =
converter.convertFromText(member, ConnectionEndpoint.class, null);
-
- return StringUtils.concat("service:jmx:rmi://", connectionEndpoint.getHost(), ":",
- connectionEndpoint.getPort(), "/jndi/rmi://", connectionEndpoint.getHost(), ":",
- connectionEndpoint.getPort(), "/jmxrmi");
+ String hostAndPort = connectionEndpoint.getHost() + ":" + connectionEndpoint.getPort();
+ return String.format("service:jmx:rmi://%s/jndi/rmi://%s/jmxrmi", hostAndPort, hostAndPort);
} catch (Exception e) {
throw new IllegalArgumentException(
CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE);
@@ -2201,7 +2101,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M})
public Result startJVisualVM(@CliOption(key = CliStrings.START_JCONSOLE__J,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_JCONSOLE__J__HELP) final List<String> jvmArgs) {
try {
String[] jvisualvmCommandLine = createJVisualVMCommandLine(jvmArgs);
@@ -2219,17 +2118,13 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
InfoResultData infoResultData = ResultBuilder.createInfoResultData();
- if (!StringUtils.isBlank(jvisualvmProcessOutput)) {
+ if (StringUtils.isNotBlank(jvisualvmProcessOutput)) {
infoResultData.addLine(StringUtils.LINE_SEPARATOR);
infoResultData.addLine(jvisualvmProcessOutput);
}
return ResultBuilder.buildResult(infoResultData);
- } catch (GemFireException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
return ResultBuilder.createShellClientErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -2285,7 +2180,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
unspecifiedDefaultValue = "http://localhost:7070/pulse",
help = CliStrings.START_PULSE__URL__HELP) final String url) {
try {
- if (!StringUtils.isBlank(url)) {
+ if (StringUtils.isNotBlank(url)) {
browse(URI.create(url));
return ResultBuilder.createInfoResult(CliStrings.START_PULSE__RUN);
} else {
@@ -2298,14 +2193,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
String pulseURL =
(String) operationInvoker.getAttribute(managerObjectName.toString(), "PulseURL");
- if (!StringUtils.isBlank(pulseURL)) {
+ if (StringUtils.isNotBlank(pulseURL)) {
browse(URI.create(pulseURL));
return ResultBuilder
.createInfoResult(CliStrings.START_PULSE__RUN + " with URL: " + pulseURL);
} else {
String pulseMessage = (String) operationInvoker
.getAttribute(managerObjectName.toString(), "StatusMessage");
- return (!StringUtils.isBlank(pulseMessage)
+ return (StringUtils.isNotBlank(pulseMessage)
? ResultBuilder.createGemFireErrorResult(pulseMessage)
: ResultBuilder.createGemFireErrorResult(CliStrings.START_PULSE__URL__NOTFOUND));
}
@@ -2314,8 +2209,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
.format(CliStrings.GFSH_MUST_BE_CONNECTED_FOR_LAUNCHING_0, "GemFire Pulse"));
}
}
- } catch (GemFireException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
} catch (Exception e) {
return ResultBuilder.createShellClientErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
@@ -2373,7 +2266,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
try {
String geodeHome = System.getenv("GEODE_HOME");
- assertState(!StringUtils.isBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
+ assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
assertState(IOUtils.isExistingPathname(getPathToVsd()),
String.format(CliStrings.START_VSD__NOT_FOUND_ERROR_MESSAGE, geodeHome));
@@ -2393,19 +2286,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
InfoResultData infoResultData = ResultBuilder.createInfoResultData();
- if (!StringUtils.isBlank(vsdProcessOutput)) {
+ if (StringUtils.isNotBlank(vsdProcessOutput)) {
infoResultData.addLine(StringUtils.LINE_SEPARATOR);
infoResultData.addLine(vsdProcessOutput);
}
return ResultBuilder.buildResult(infoResultData);
- } catch (GemFireException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (FileNotFoundException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createShellClientErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (GemFireException | IllegalStateException | IllegalArgumentException
+ | FileNotFoundException e) {
return ResultBuilder.createShellClientErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
@@ -2489,7 +2377,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
try {
String geodeHome = System.getenv("GEODE_HOME");
- assertState(!StringUtils.isBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
+ assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
if (isConnectedAndReady()
&& (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) {
@@ -2518,7 +2406,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
InfoResultData infoResultData = ResultBuilder.createInfoResultData();
- if (!StringUtils.isBlank(dataBrowserProcessOutput)) {
+ if (StringUtils.isNotBlank(dataBrowserProcessOutput)) {
infoResultData.addLine(StringUtils.LINE_SEPARATOR);
infoResultData.addLine(dataBrowserProcessOutput);
}
@@ -2528,9 +2416,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
return ResultBuilder.createUserErrorResult(CliStrings.format(
CliStrings.GFSH_MUST_BE_CONNECTED_VIA_JMX_FOR_LAUNCHING_0, "GemFire DataBrowser"));
}
- } catch (IllegalArgumentException e) {
- return ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
return ResultBuilder.createUserErrorResult(e.getMessage());
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
index c9e79b0..ad344ff 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
@@ -20,11 +20,11 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_P
import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.DSFIDFactory;
import org.apache.geode.internal.lang.Initializer;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.lang.SystemUtils;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.internal.util.PasswordUtil;
@@ -181,7 +181,7 @@ public class ShellCommands implements CommandMarker {
if (locatorResponseException != null) {
String locatorResponseExceptionMessage = locatorResponseException.getMessage();
- locatorResponseExceptionMessage = (!StringUtils.isBlank(locatorResponseExceptionMessage)
+ locatorResponseExceptionMessage = (StringUtils.isNotBlank(locatorResponseExceptionMessage)
? locatorResponseExceptionMessage : locatorResponseException.toString());
exceptionMessage = "Exception caused JMX Manager startup to fail because: '"
.concat(locatorResponseExceptionMessage).concat("'");
@@ -560,7 +560,7 @@ public class ShellCommands implements CommandMarker {
try {
KeyManagerFactory keyManagerFactory = null;
- if (!StringUtils.isBlank(keystoreToUse)) {
+ if (StringUtils.isNotBlank(keystoreToUse)) {
KeyStore clientKeys = KeyStore.getInstance("JKS");
keyStoreStream = new FileInputStream(keystoreToUse);
clientKeys.load(keyStoreStream, keystorePasswordToUse.toCharArray());
@@ -572,7 +572,7 @@ public class ShellCommands implements CommandMarker {
// load server public key
TrustManagerFactory trustManagerFactory = null;
- if (!StringUtils.isBlank(truststoreToUse)) {
+ if (StringUtils.isNotBlank(truststoreToUse)) {
KeyStore serverPub = KeyStore.getInstance("JKS");
trustStoreStream = new FileInputStream(truststoreToUse);
serverPub.load(trustStoreStream, truststorePasswordToUse.toCharArray());
@@ -622,7 +622,7 @@ public class ShellCommands implements CommandMarker {
URL gfSecurityPropertiesUrl = null;
// Case 1: User has specified gfSecurity properties file
- if (!StringUtils.isBlank(gfSecurityPropertiesPathToUse)) {
+ if (StringUtils.isNotBlank(gfSecurityPropertiesPathToUse)) {
// User specified gfSecurity properties doesn't exist
if (!IOUtils.isExistingPathname(gfSecurityPropertiesPathToUse)) {
gfshInstance
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java
index 3fadd96..d1e3f9e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.management.internal.cli.converters;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.management.cli.ConverterHint;
import org.springframework.shell.core.Completion;
import org.springframework.shell.core.Converter;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java
index 59851da..20b37b3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java
@@ -14,20 +14,19 @@
*/
package org.apache.geode.management.internal.cli.converters;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
import org.apache.geode.management.cli.ConverterHint;
import org.apache.geode.management.internal.ManagementConstants;
import org.apache.geode.management.internal.cli.shell.Gfsh;
-
import org.springframework.shell.core.Completion;
import org.springframework.shell.core.Converter;
import org.springframework.shell.core.MethodTarget;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
/**
*
* @since GemFire 7.0
@@ -64,7 +63,7 @@ public class GatewaySenderIdConverter implements Converter<String> {
Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
final String[] gatewaySenderIdArray = (String[]) gfsh.getOperationInvoker().invoke(
- ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "listGatwaySenders",
+ ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "listGatewaySenders",
new Object[0], new String[0]);
if (gatewaySenderIdArray != null && gatewaySenderIdArray.length != 0) {
gatewaySenderIds = new TreeSet<String>(Arrays.asList(gatewaySenderIdArray));
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java
index b5d1b0c..d1a1107 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java
@@ -15,6 +15,11 @@
package org.apache.geode.management.internal.cli.domain;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.internal.lang.MutableIdentifiable;
+import org.apache.geode.internal.lang.ObjectUtils;
+
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
@@ -23,11 +28,6 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
-import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.internal.lang.MutableIdentifiable;
-import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
-
/**
* The DiskStoreDetails class captures information about a particular disk store for a GemFire
* distributed system member. Each disk store for a member should be captured in separate instance
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java
index 64bb512..335302e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java
@@ -15,13 +15,13 @@
package org.apache.geode.management.internal.cli.domain;
-import java.io.Serializable;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.query.Index;
import org.apache.geode.cache.query.IndexStatistics;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
+
+import java.io.Serializable;
/**
* The IndexDetails class encapsulates information for an Index on a Region in the GemFire Cache.
@@ -91,11 +91,11 @@ public class IndexDetails implements Comparable<IndexDetails>, Serializable {
}
public IndexDetails(final String memberId, final String regionPath, final String indexName) {
- assertValidArgument(!StringUtils.isBlank(memberId),
+ assertValidArgument(StringUtils.isNotBlank(memberId),
"The member having a region with an index must be specified!");
- assertValidArgument(!StringUtils.isBlank(regionPath),
+ assertValidArgument(StringUtils.isNotBlank(regionPath),
"The region in member (%1$s) with an index must be specified!", memberId);
- assertValidArgument(!StringUtils.isBlank(indexName),
+ assertValidArgument(StringUtils.isNotBlank(indexName),
"The name of the index on region (%1$s) of member (%2$s) must be specified!", regionPath,
memberId);
this.memberId = memberId;
@@ -307,7 +307,7 @@ public class IndexDetails implements Comparable<IndexDetails>, Serializable {
}
IndexType(final String description) {
- assertValidArgument(!StringUtils.isBlank(description),
+ assertValidArgument(StringUtils.isNotBlank(description),
"The description for the IndexType must be specified!");
this.description = description;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
index 4c241d0..68cc2e0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
@@ -15,11 +15,7 @@
package org.apache.geode.management.internal.cli.functions;
-import java.io.File;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.DataPolicy;
@@ -35,14 +31,17 @@ import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.InternalEntity;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.util.ArrayUtils;
import org.apache.geode.management.internal.cli.domain.DiskStoreDetails;
import org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException;
-
import org.apache.logging.log4j.Logger;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
/**
* The DescribeDiskStoreFunction class is an implementation of a GemFire Function used to collect
* information and details about a particular disk store for a particular GemFire distributed system
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
index 57d209b..c688d7a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.management.internal.cli.functions;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.execute.FunctionAdapter;
import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.distributed.DistributedMember;
@@ -21,7 +22,6 @@ import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.InternalEntity;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus;
public class FetchSharedConfigurationStatusFunction extends FunctionAdapter
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
index c99f84a..0811931 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
@@ -14,12 +14,7 @@
*/
package org.apache.geode.management.internal.cli.functions;
-import java.util.Set;
-
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.CacheListener;
@@ -38,6 +33,7 @@ import org.apache.geode.cache.execute.FunctionAdapter;
import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.cache.execute.ResultSender;
import org.apache.geode.compression.Compressor;
+import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.InternalEntity;
import org.apache.geode.internal.cache.xmlcache.CacheXml;
import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -48,6 +44,9 @@ import org.apache.geode.management.internal.cli.exceptions.CreateSubregionExcept
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.RegionPath;
import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Set;
/**
*
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
index 4383044..78879d3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.management.internal.cli.help;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.management.internal.cli.GfshParser;
import org.apache.geode.management.internal.cli.shell.Gfsh;
@@ -33,7 +33,7 @@ public class HelpBlock {
public HelpBlock() {}
public HelpBlock(String data) {
- if (!StringUtils.isBlank(data)) {
+ if (StringUtils.isNotBlank(data)) {
this.data = data;
this.level = 0;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
index 9dbf59c..3525013 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
@@ -231,7 +231,7 @@ public class Helper {
}
// Now comes the turn to display synopsis if any
- if (!StringUtils.isBlank(cliCommand.help())) {
+ if (StringUtils.isNotBlank(cliCommand.help())) {
HelpBlock synopsis = new HelpBlock(SYNOPSIS_NAME);
synopsis.addChild(new HelpBlock(cliCommand.help()));
root.addChild(synopsis);
@@ -259,7 +259,7 @@ public class Helper {
HelpBlock getOptionDetail(CliOption cliOption) {
HelpBlock optionNode = new HelpBlock(getPrimaryKey(cliOption));
String help = cliOption.help();
- optionNode.addChild(new HelpBlock((!StringUtils.isBlank(help) ? help : "")));
+ optionNode.addChild(new HelpBlock((StringUtils.isNotBlank(help) ? help : "")));
if (getSynonyms(cliOption).size() > 0) {
StringBuilder builder = new StringBuilder();
for (String string : getSynonyms(cliOption)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java
index 9bd2bf9..6332540 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java
@@ -14,15 +14,13 @@
*/
package org.apache.geode.management.internal.cli.result;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.cli.json.GfJsonException;
import org.apache.geode.management.internal.cli.json.GfJsonObject;
+import java.util.Collection;
+import java.util.List;
+
/**
*
*
@@ -170,7 +168,7 @@ public class ResultBuilder {
}
public static <T extends CliJsonSerializable> ObjectResultData<T> createObjectResultData() {
- return new ObjectResultData<T>();
+ return new ObjectResultData<>();
}
// public static CatalogedResultData createCatalogedResultData() {
@@ -228,13 +226,13 @@ public class ResultBuilder {
* Bad Response.
*/
public static Result fromJson(String json) {
- Result result = null;
+ Result result;
try {
GfJsonObject jsonObject = new GfJsonObject(json);
String contentType = jsonObject.getString("contentType");
GfJsonObject data = jsonObject.getJSONObject("data");
- AbstractResultData resultData = null;
+ AbstractResultData resultData;
if (ResultData.TYPE_TABULAR.equals(contentType)) {
resultData = new TabularResultData(data);
} /*
@@ -247,7 +245,7 @@ public class ResultBuilder {
} else if (ResultData.TYPE_COMPOSITE.equals(contentType)) {
resultData = new CompositeResultData(data);
} else if (ResultData.TYPE_OBJECT.equals(contentType)) {
- resultData = new ObjectResultData<CliJsonSerializable>(data);
+ resultData = new ObjectResultData<>(data);
} else {
ErrorResultData errorResultData = new ErrorResultData();
errorResultData.addLine("Can not detect result type, unknown response format: " + json);
@@ -284,7 +282,7 @@ public class ResultBuilder {
* @return Read only ResultData of the same type
*/
static ResultData getReadOnlyResultData(ResultData resultData) {
- ResultData wrapperResultData = null;
+ ResultData wrapperResultData;
String contentType = resultData.getType();
if (ResultData.TYPE_TABULAR.equals(contentType)) {
wrapperResultData = new TabularResultData(resultData.getGfJsonObject()) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java
index da3c4ae..ff23512 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java
@@ -53,12 +53,12 @@ package org.apache.geode.management.internal.cli.result;
*
* @since GemFire 7.0
*/
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.management.internal.cli.GfshParser;
+
import java.util.ArrayList;
import java.util.List;
-import org.apache.geode.management.internal.cli.GfshParser;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-
public class TableBuilder {
public static Table newTable() {
@@ -66,7 +66,7 @@ public class TableBuilder {
}
public static class Table {
- private final List<RowGroup> rowGroups = new ArrayList<RowGroup>();
+ private final List<RowGroup> rowGroups = new ArrayList<>();
private String columnSeparator = " ";
private boolean isTabularResult = false;
@@ -138,7 +138,7 @@ public class TableBuilder {
}
public String buildTable() {
- StringBuffer stringBuffer = new StringBuffer();
+ StringBuilder stringBuffer = new StringBuilder();
for (RowGroup rowGroup : this.rowGroups) {
stringBuffer.append(rowGroup.buildRowGroup(isTabularResult));
}
@@ -147,7 +147,7 @@ public class TableBuilder {
}
public List<String> buildTableList() {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
for (RowGroup rowGroup : this.rowGroups) {
list.add(rowGroup.buildRowGroup(isTabularResult));
}
@@ -169,7 +169,7 @@ public class TableBuilder {
*/
public static class RowGroup {
private final Table table;
- private final List<Row> rows = new ArrayList<Row>();
+ private final List<Row> rows = new ArrayList<>();
private int[] colSizes;
private String columnSeparator;
@@ -202,11 +202,11 @@ public class TableBuilder {
public String buildRowGroup(boolean isTabularResult) {
this.colSizes = computeColSizes(isTabularResult);
- StringBuffer stringBuffer = new StringBuffer();
+ StringBuilder stringBuffer = new StringBuilder();
for (Row row : rows) {
String builtRow = row.buildRow(isTabularResult);
stringBuffer.append(builtRow);
- if (!builtRow.trim().isEmpty() || row.isBlank) {
+ if (StringUtils.isNotBlank(builtRow) || row.isBlank) {
stringBuffer.append(GfshParser.LINE_SEPARATOR);
}
}
@@ -275,7 +275,7 @@ public class TableBuilder {
public static class Row {
private final RowGroup rowGroup;
private final Character rowSeparator;
- private final List<Column> columns = new ArrayList<Column>();
+ private final List<Column> columns = new ArrayList<>();
boolean isBlank;
private boolean isTablewideSeparator;
@@ -335,7 +335,7 @@ public class TableBuilder {
}
private String buildRow(boolean isTabularResult) {
- StringBuffer stringBuffer = new StringBuffer();
+ StringBuilder stringBuffer = new StringBuilder();
if (this.rowSeparator != null) {
if (isTablewideSeparator) {
int maxColLength = this.rowGroup.getTable().getMaxLength();
@@ -383,8 +383,8 @@ public class TableBuilder {
}
private static enum Align {
- LEFT, RIGHT, CENTER;
- };
+ LEFT, RIGHT, CENTER
+ }
private static class Column {
@@ -411,7 +411,7 @@ public class TableBuilder {
// This can happen because colSizes are re-computed
// to fit the screen width
if (this.stringValue.length() > colWidth) {
- StringBuffer stringBuffer = new StringBuffer();
+ StringBuilder stringBuffer = new StringBuilder();
int endIndex = colWidth - 2;
if (endIndex < 0)
return "";
@@ -422,7 +422,7 @@ public class TableBuilder {
if (trimIt)
numSpaces = 0;
- StringBuffer stringBuffer = new StringBuffer();
+ StringBuilder stringBuffer = new StringBuilder();
switch (align) {
case LEFT:
[5/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
index 0b11bf1..388f838 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
@@ -14,7 +14,49 @@
*/
package org.apache.geode.internal.cache.tier.sockets;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.CONFLATE_EVENTS;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.CancelCriterion;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.GemFireConfigException;
+import org.apache.geode.InternalGemFireException;
+import org.apache.geode.cache.GatewayConfigurationException;
+import org.apache.geode.cache.client.PoolFactory;
+import org.apache.geode.cache.client.ServerRefusedConnectionException;
+import org.apache.geode.cache.client.internal.Connection;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.LonerDistributionManager;
+import org.apache.geode.distributed.internal.ServerLocation;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.ClassLoadUtil;
+import org.apache.geode.internal.HeapDataOutputStream;
+import org.apache.geode.internal.InternalDataSerializer;
+import org.apache.geode.internal.InternalInstantiator;
+import org.apache.geode.internal.Version;
+import org.apache.geode.internal.VersionedDataInputStream;
+import org.apache.geode.internal.VersionedDataOutputStream;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.ClientHandShake;
+import org.apache.geode.internal.cache.tier.ConnectionProxy;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.pdx.internal.PeerTypeRegistration;
+import org.apache.geode.security.AuthInitialize;
+import org.apache.geode.security.AuthenticationFailedException;
+import org.apache.geode.security.AuthenticationRequiredException;
+import org.apache.geode.security.Authenticator;
+import org.apache.geode.security.GemFireSecurityException;
+import org.apache.logging.log4j.Logger;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -49,7 +91,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-
import javax.crypto.Cipher;
import javax.crypto.KeyAgreement;
import javax.crypto.SecretKey;
@@ -58,46 +99,6 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLSocket;
-import org.apache.geode.CancelCriterion;
-import org.apache.geode.DataSerializer;
-import org.apache.geode.GemFireConfigException;
-import org.apache.geode.InternalGemFireException;
-import org.apache.geode.cache.GatewayConfigurationException;
-import org.apache.geode.cache.client.PoolFactory;
-import org.apache.geode.cache.client.ServerRefusedConnectionException;
-import org.apache.geode.cache.client.internal.Connection;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.distributed.internal.DM;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.distributed.internal.LonerDistributionManager;
-import org.apache.geode.distributed.internal.ServerLocation;
-import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.internal.ClassLoadUtil;
-import org.apache.geode.internal.HeapDataOutputStream;
-import org.apache.geode.internal.InternalDataSerializer;
-import org.apache.geode.internal.InternalInstantiator;
-import org.apache.geode.internal.Version;
-import org.apache.geode.internal.VersionedDataInputStream;
-import org.apache.geode.internal.VersionedDataOutputStream;
-import org.apache.geode.internal.cache.tier.Acceptor;
-import org.apache.geode.internal.cache.tier.ClientHandShake;
-import org.apache.geode.internal.cache.tier.ConnectionProxy;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.logging.InternalLogWriter;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.security.IntegratedSecurityService;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.pdx.internal.PeerTypeRegistration;
-import org.apache.geode.security.AuthInitialize;
-import org.apache.geode.security.AuthenticationFailedException;
-import org.apache.geode.security.AuthenticationRequiredException;
-import org.apache.geode.security.Authenticator;
-import org.apache.geode.security.GemFireSecurityException;
-import org.apache.logging.log4j.Logger;
-
public class HandShake implements ClientHandShake {
private static final Logger logger = LogService.getLogger();
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/lang/StringUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/lang/StringUtils.java b/geode-core/src/main/java/org/apache/geode/internal/lang/StringUtils.java
index 499d546..8a44564 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/lang/StringUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/lang/StringUtils.java
@@ -22,91 +22,30 @@ import org.apache.geode.internal.cache.Token;
* The StringUtils is an abstract utility class for working with and invoking operations on String
* literals.
* <p/>
- *
+ *
* @see java.lang.String
* @since GemFire 7.0
*/
@SuppressWarnings("unused")
-public abstract class StringUtils {
+@Deprecated
+public class StringUtils extends org.apache.commons.lang.StringUtils {
public static final String COMMA_DELIMITER = ",";
- public static final String EMPTY_STRING = "";
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static final String SPACE = " ";
- public static final String UTF_8 = "UTF-8";
-
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
- public static final String[] SPACES = {"", " ", " ", " ", " ", " ", " ", " ",
- " ", " ", " "};
-
- /**
- * Concatenates all Objects in the array into a single String by calling toString on the Object.
- * </p>
- *
- * @param values the Object elements of the array to be concatenated into the String.
- * @return a single String with all the individual Objects in the array concatenated.
- * @see #concat(Object[], String)
- */
- public static String concat(final Object... values) {
- return concat(values, EMPTY_STRING);
- }
-
- /**
- * Concatenates all Objects in the array into a single String using the Object's toString method,
- * delimited by the specified delimiter.
- * </p>
- *
- * @param values an array of Objects to concatenate into a single String value.
- * @param delimiter the String value to use as a separator between the individual Object values.
- * If delimiter is null, then a empty String is used.
- * @return a single String with all the individual Objects of the array concatenated together,
- * separated by the specified delimiter.
- * @see java.lang.Object#toString()
- * @see java.lang.StringBuilder
- */
- public static String concat(final Object[] values, String delimiter) {
- delimiter = ObjectUtils.defaultIfNull(delimiter, EMPTY_STRING);
-
- final StringBuilder buffer = new StringBuilder();
- int count = 0;
-
- if (values != null) {
- for (Object value : values) {
- buffer.append(count++ > 0 ? delimiter : EMPTY_STRING);
- buffer.append(value);
- }
- }
-
- return buffer.toString();
- }
+ private static final int MAX_ARRAY_ELEMENTS_TO_CONVERT =
+ Integer.getInteger("StringUtils.MAX_ARRAY_ELEMENTS_TO_CONVERT", 16);
- /**
- * Returns the first non-null, non-empty and non-blank String value in the array of String values.
- * </p>
- *
- * @param values an array of String values, usually consisting of the preferred value followed by
- * default values if any value in the array of String values is null, empty or blank.
- * @return the first non-null, non-empty and non-blank String value in the array of Strings. If
- * all values are either null, empty or blank then null is returned.
- * @see #isBlank(String)
- */
- public static String defaultIfBlank(final String... values) {
- if (values != null) {
- for (final String value : values) {
- if (!isBlank(value)) {
- return value;
- }
- }
- }
- return null;
+ public static String nullifyIfBlank(final String value) {
+ return isBlank(value) ? null : value;
}
/**
* Returns only the digits (0..9) from the specified String value.
* </p>
- *
+ *
* @param value the String value from which to extract digits.
* @return only the digits from the specified String value. If the String is null or contains no
* digits, then this method returns an empty String.
@@ -126,156 +65,7 @@ public abstract class StringUtils {
return buffer.toString();
}
- /**
- * Returns only the letters (a..zA..Z) from the specified String value.
- * </p>
- *
- * @param value the String value from which to extract letters.
- * @return only the letters from the specified String value. If the String is null or contains no
- * letters, then this method returns an empty String.
- * @see java.lang.Character#isLetter(char)
- */
- public static String getLettersOnly(final String value) {
- final StringBuilder buffer = new StringBuilder();
-
- if (value != null) {
- for (final char chr : value.toCharArray()) {
- if (Character.isLetter(chr)) {
- buffer.append(chr);
- }
- }
- }
-
- return buffer.toString();
- }
-
- /**
- * Gets a number of spaces determined by number.
- * </p>
- *
- * @param number an integer value indicating the number of spaces to return.
- * @return a String value containing a number of spaces given by number.
- */
- public static String getSpaces(int number) {
- final StringBuilder spaces = new StringBuilder(SPACES[Math.min(number, SPACES.length - 1)]);
-
- do {
- number -= (SPACES.length - 1);
- number = Math.max(number, 0);
- spaces.append(SPACES[Math.min(number, SPACES.length - 1)]);
- } while (number > 0);
-
- return spaces.toString();
- }
-
- /**
- * Determines whether the specified String value is blank, which is true if it is null, an empty
- * String or a String containing only spaces (blanks).
- * </p>
- *
- * @param value the String value used in the determination for the "blank" check.
- * @return a boolean value indicating whether the specified String is blank.
- * @see #isEmpty(String)
- */
- public static boolean isBlank(final String value) {
- return (value == null || EMPTY_STRING.equals(value.trim()));
- }
-
- /**
- * Determines whether the specified String value is empty, which is true if and only if the value
- * is the empty String.
- * </p>
- *
- * @param value the String value used in the determination of the "empty" check.
- * @return a boolean value indicating if the specified String is empty.
- * @see #isBlank(String)
- */
- public static boolean isEmpty(final String value) {
- return EMPTY_STRING.equals(value);
- }
-
- /**
- * Pads the specified String value by appending the specified character up to the given length.
- * </p>
- *
- * @param value the String value to pad by appending 'paddingCharacter' to the end.
- * @param paddingCharacter the character used to pad the end of the String value.
- * @param length an int value indicating the final length of the String value with padding of the
- * 'paddingCharacter'.
- * @return the String value padded with the specified character by appending 'paddingCharacter' to
- * the end of the String value up to the given length.
- * @throws NullPointerException if the String value is null.
- */
- public static String padEnding(final String value, final char paddingCharacter,
- final int length) {
- if (value == null) {
- throw new NullPointerException("The String value to pad cannot be null!");
- }
-
- final StringBuilder buffer = new StringBuilder(value);
-
- for (int valueLength = value.length(); valueLength < length; valueLength++) {
- buffer.append(paddingCharacter);
- }
-
- return buffer.toString();
- }
-
- /**
- * A null-safe implementation of the String.toLowerCase method.
- * </p>
- *
- * @param value a String value to convert to lower case.
- * @return a lower case representation of the specified String value.
- * @see java.lang.String#toLowerCase()
- */
- public static String toLowerCase(final String value) {
- return (value == null ? null : value.toLowerCase());
- }
-
- /**
- * A null-safe implementation of the String.toUpperCase method.
- * </p>
- *
- * @param value a String value to convert to upper case.
- * @return an upper case representation of the specified String value.
- * @see java.lang.String#toUpperCase()
- */
- public static String toUpperCase(final String value) {
- return (value == null ? null : value.toUpperCase());
- }
- /**
- * A method to trim the value of a String and guard against null values.
- * <p/>
- *
- * @param value the String value that will be trimmed if not null.
- * @return null if the String value is null or the trimmed version of the String value if String
- * value is not null.
- * @see java.lang.String#trim()
- */
- public static String trim(final String value) {
- return (value == null ? null : value.trim());
- }
-
- /**
- * Null-safe implementation of String truncate using substring. Truncates the specified String
- * value to the specified length. Returns null if the String value is null.
- * </p>
- *
- * @param value the String value to truncate.
- * @param length an int value indicating the length to truncate the String value to.
- * @return the String value truncated to specified length, or null if the String value is null.
- * @throws IllegalArgumentException if the value of length is less than 0.
- * @see java.lang.String#substring(int, int)
- */
- public static String truncate(final String value, final int length) {
- if (length < 0) {
- throw new IllegalArgumentException("Length must be greater than equal to 0!");
- }
-
- return (value == null ? null : value.substring(0, Math.min(value.length(), length)));
- }
/**
* Gets the value of the specified Object as a String. If the Object is null then the first
@@ -283,9 +73,9 @@ public abstract class StringUtils {
* String values is null or all the elements in the default String values array are null, then the
* value of String.valueOf(value) is returned.
* </p>
- *
+ *
* @param value the Object who's String representation is being evaluated.
- * @param defaultValues an array of default String values to assess if the specified Object value
+ * @param defaultValue an array of default String values to assess if the specified Object value
* is null.
* @return a String representation of the specified Object value or one of the default String
* values from the array if the Object value is null. If either the default String array
@@ -293,20 +83,12 @@ public abstract class StringUtils {
* returned.
* @see java.lang.String#valueOf(Object)
*/
- public static String valueOf(final Object value, final String... defaultValues) {
- if (value != null) {
- return value.toString();
- } else {
- if (defaultValues != null) {
- for (String defaultValue : defaultValues) {
- if (defaultValue != null) {
- return defaultValue;
- }
- }
- }
+ public static String defaultString(final Object value, final String defaultValue) {
+ return value == null ? defaultValue : value.toString();
+ }
- return String.valueOf(value);
- }
+ public static String defaultString(final Object value) {
+ return value == null ? EMPTY : value.toString();
}
/**
@@ -314,7 +96,7 @@ public abstract class StringUtils {
* characters in each line, indenting all subsequent lines with the indent. If the indent is null,
* then an empty String is used.
* </p>
- *
+ *
* @param line a String containing the line of text to wrap.
* @param widthInCharacters an integer value indicating the width of each line measured by the
* number of characters.
@@ -324,18 +106,19 @@ public abstract class StringUtils {
* boundaries within the given width on any given split.
* @throws NullPointerException if the line of text is null.
*/
+ // Can be removed when commons is updated.
public static String wrap(String line, final int widthInCharacters, String indent) {
final StringBuilder buffer = new StringBuilder();
int lineCount = 1;
- int spaceIndex = -1;
+ int spaceIndex;
// if indent is null, then do not indent the wrapped lines
- indent = valueOf(indent, EMPTY_STRING);
+ indent = StringUtils.defaultString(indent);
while (line.length() > widthInCharacters) {
spaceIndex = line.substring(0, widthInCharacters).lastIndexOf(SPACE);
- buffer.append(lineCount++ > 1 ? indent : EMPTY_STRING);
+ buffer.append(lineCount++ > 1 ? indent : EMPTY);
// throws IndexOutOfBoundsException if spaceIndex is -1, implying no word boundary was found
// within
// the given width; this also avoids the infinite loop
@@ -351,13 +134,10 @@ public abstract class StringUtils {
return buffer.toString();
}
- private static final int MAX_ARRAY_ELEMENTS_TO_CONVERT =
- Integer.getInteger("StringUtils.MAX_ARRAY_ELEMENTS_TO_CONVERT", 16);
-
/**
* Used to convert the given object to a String. If anything goes wrong in this conversion put
* some info about what went wrong on the result string but do not throw an exception.
- *
+ *
* @param o the object to convert to a string
* @return the string from of the given object.
*/
@@ -373,7 +153,7 @@ public abstract class StringUtils {
* Convert an object to a string and return it. Handled CacheDeserializables without having them
* change the form they store. If deserialization is needed and fails then the string contains a
* message saying so instead of throwing an exception.
- *
+ *
* @param o the object to convert to a string
* @param convertArrayContents if true then the contents of the array will be in the string;
* otherwise just the array identity
@@ -414,13 +194,15 @@ public abstract class StringUtils {
}
}
- private static String arrayToString(Object[] a, int maxArrayElements) {
+
+ private static <T> String arrayToString(T[] a, int maxArrayElements) {
if (maxArrayElements < 0) {
maxArrayElements = 0;
}
if (a == null) {
return "null";
}
+ String className = a.getClass().getSimpleName();
int iMax = a.length;
if (iMax > maxArrayElements) {
iMax = maxArrayElements;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
index 2e47556..4c50851 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
@@ -80,8 +80,8 @@ public class SystemUtils {
actualVersionDigits = StringUtils.getDigitsOnly(System.getProperty("java.version"));
}
- String expectedVersionDigits = StringUtils.padEnding(StringUtils.getDigitsOnly(expectedVersion),
- '0', actualVersionDigits.length());
+ String expectedVersionDigits = StringUtils.rightPad(StringUtils.getDigitsOnly(expectedVersion),
+ actualVersionDigits.length(), '0');
try {
return Long.parseLong(actualVersionDigits) >= Long.parseLong(expectedVersionDigits);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/process/FileProcessController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/FileProcessController.java b/geode-core/src/main/java/org/apache/geode/internal/process/FileProcessController.java
index 629740c..c8ec49d 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/process/FileProcessController.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/FileProcessController.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.internal.process;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.internal.logging.LogService;
@@ -101,8 +102,7 @@ public class FileProcessController implements ProcessController {
LocalizedStrings.Launcher_ATTACH_API_NOT_FOUND_ERROR_MESSAGE.toLocalizedString());
}
- private void stop(final File workingDir, final String stopRequestFileName)
- throws UnableToControlProcessException, IOException {
+ private void stop(final File workingDir, final String stopRequestFileName) throws IOException {
final File stopRequestFile = new File(workingDir, stopRequestFileName);
if (!stopRequestFile.exists()) {
stopRequestFile.createNewFile();
@@ -110,11 +110,10 @@ public class FileProcessController implements ProcessController {
}
private String status(final File workingDir, final String statusRequestFileName,
- final String statusFileName)
- throws UnableToControlProcessException, IOException, InterruptedException, TimeoutException {
+ final String statusFileName) throws IOException, InterruptedException, TimeoutException {
// monitor for statusFile
final File statusFile = new File(workingDir, statusFileName);
- final AtomicReference<String> statusRef = new AtomicReference<String>();
+ final AtomicReference<String> statusRef = new AtomicReference<>();
final ControlRequestHandler statusHandler = new ControlRequestHandler() {
@Override
@@ -162,7 +161,7 @@ public class FileProcessController implements ProcessController {
}
final String lines = statusRef.get();
- if (null == lines || lines.trim().isEmpty()) {
+ if (StringUtils.isBlank(lines)) {
throw new IllegalStateException("Failed to read status file");
}
return lines;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/process/signal/Signal.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/signal/Signal.java b/geode-core/src/main/java/org/apache/geode/internal/process/signal/Signal.java
index faab4ed..78b19db 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/process/signal/Signal.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/signal/Signal.java
@@ -15,7 +15,7 @@
package org.apache.geode.internal.process.signal;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
/**
* Signals defined in the enumerated type were based on Open BSD and the IBM JVM...
@@ -78,7 +78,7 @@ public enum Signal {
private final String name;
Signal(final int number, final String name, final SignalType type, final String description) {
- assertValidArgument(!StringUtils.isBlank(name), "The name of the signal must be specified!");
+ assertValidArgument(StringUtils.isNotBlank(name), "The name of the signal must be specified!");
this.number = number;
this.name = name;
this.type = type;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java b/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
index 8366930..600d546 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
@@ -293,7 +293,7 @@ public class IntegratedSecurityService implements SecurityService {
String clientAuthenticatorConfig = securityProps.getProperty(SECURITY_CLIENT_AUTHENTICATOR);
String peerAuthenticatorConfig = securityProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
- if (!StringUtils.isBlank(shiroConfig)) {
+ if (StringUtils.isNotBlank(shiroConfig)) {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:" + shiroConfig);
// we will need to make sure that shiro uses a case sensitive permission resolver
@@ -311,20 +311,20 @@ public class IntegratedSecurityService implements SecurityService {
isPeerAuthenticator = false;
}
// only set up shiro realm if user has implemented SecurityManager
- else if (!StringUtils.isBlank(securityManagerConfig)) {
+ else if (StringUtils.isNotBlank(securityManagerConfig)) {
SecurityManager securityManager = SecurityService
.getObjectOfTypeFromClassName(securityManagerConfig, SecurityManager.class);
securityManager.init(securityProps);
this.setSecurityManager(securityManager);
} else {
isIntegratedSecurity = null;
- isClientAuthenticator = !StringUtils.isBlank(clientAuthenticatorConfig);
- isPeerAuthenticator = !StringUtils.isBlank(peerAuthenticatorConfig);
+ isClientAuthenticator = StringUtils.isNotBlank(clientAuthenticatorConfig);
+ isPeerAuthenticator = StringUtils.isNotBlank(peerAuthenticatorConfig);
}
// this initializes the post processor
String customPostProcessor = securityProps.getProperty(SECURITY_POST_PROCESSOR);
- if (!StringUtils.isBlank(customPostProcessor)) {
+ if (StringUtils.isNotBlank(customPostProcessor)) {
postProcessor =
SecurityService.getObjectOfTypeFromClassName(customPostProcessor, PostProcessor.class);
postProcessor.init(securityProps);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java b/geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java
index 6f1c7cc..6f1292a 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java
@@ -15,15 +15,12 @@
package org.apache.geode.internal.util;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.internal.offheap.annotations.Unretained;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
-import java.util.Objects;
-import java.util.RandomAccess;
-
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.offheap.annotations.Unretained;
/**
*
@@ -82,7 +79,7 @@ public abstract class ArrayUtils {
if (array != null) {
for (final Object element : array) {
- buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY_STRING).append(element);
+ buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY).append(element);
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java b/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
index c1a1952..031f827 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.util;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -186,7 +186,7 @@ public abstract class IOUtils {
public static String getFilename(final String pathname) {
String filename = pathname;
- if (!StringUtils.isBlank(filename)) {
+ if (StringUtils.isNotBlank(filename)) {
final int index = filename.lastIndexOf(File.separator);
filename = (index == -1 ? filename : filename.substring(index + 1));
}
@@ -205,7 +205,7 @@ public abstract class IOUtils {
* @see java.io.File#exists()
*/
public static boolean isExistingPathname(final String pathname) {
- return (!StringUtils.isBlank(pathname) && new File(pathname).exists());
+ return (StringUtils.isNotBlank(pathname) && new File(pathname).exists());
}
/**
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java
index ba15508..3bd442a 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java
@@ -15,8 +15,8 @@
package org.apache.geode.management.internal;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.logging.log4j.Logger;
@@ -53,7 +53,7 @@ public class AgentUtil {
*/
public String findWarLocation(String warFilePrefix) {
String geodeHome = getGeodeHome();
- if (!StringUtils.isBlank(geodeHome)) {
+ if (StringUtils.isNotBlank(geodeHome)) {
String[] possibleFiles =
{geodeHome + "/tools/Extensions/" + warFilePrefix + "-" + gemfireVersion + ".war",
geodeHome + "/tools/Pulse/" + warFilePrefix + "-" + gemfireVersion + ".war",
@@ -91,7 +91,7 @@ public class AgentUtil {
}
public boolean isWebApplicationAvailable(final String warFileLocation) {
- return !StringUtils.isBlank(warFileLocation);
+ return StringUtils.isNotBlank(warFileLocation);
}
public boolean isWebApplicationAvailable(final String... warFileLocations) {
@@ -124,6 +124,6 @@ public class AgentUtil {
public boolean isGemfireHomeDefined() {
String gemfireHome = getGeodeHome();
- return !StringUtils.isBlank(gemfireHome);
+ return StringUtils.isNotBlank(gemfireHome);
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/JettyHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/JettyHelper.java b/geode-core/src/main/java/org/apache/geode/management/internal/JettyHelper.java
index 7c26297..92987cb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/JettyHelper.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/JettyHelper.java
@@ -14,9 +14,10 @@
*/
package org.apache.geode.management.internal;
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.GemFireConfigException;
+import org.apache.geode.internal.admin.SSLConfig;
+import org.apache.geode.internal.logging.LogService;
import org.apache.logging.log4j.Logger;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Connector;
@@ -30,10 +31,8 @@ import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
-import org.apache.geode.GemFireConfigException;
-import org.apache.geode.internal.admin.SSLConfig;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.logging.LogService;
+import java.io.File;
+import java.util.concurrent.CountDownLatch;
/**
* @since GemFire 8.1
@@ -70,13 +69,13 @@ public class JettyHelper {
if (sslConfig.isEnabled()) {
SslContextFactory sslContextFactory = new SslContextFactory();
- if (!StringUtils.isBlank(sslConfig.getAlias())) {
+ if (StringUtils.isNotBlank(sslConfig.getAlias())) {
sslContextFactory.setCertAlias(sslConfig.getAlias());
}
sslContextFactory.setNeedClientAuth(sslConfig.isRequireAuth());
- if (!StringUtils.isBlank(sslConfig.getCiphers())
+ if (StringUtils.isNotBlank(sslConfig.getCiphers())
&& !"any".equalsIgnoreCase(sslConfig.getCiphers())) {
// If use has mentioned "any" let the SSL layer decide on the ciphers
sslContextFactory.setIncludeCipherSuites(SSLUtil.readArray(sslConfig.getCiphers()));
@@ -97,19 +96,19 @@ public class JettyHelper {
sslContextFactory.setKeyStorePath(sslConfig.getKeystore());
- if (!StringUtils.isBlank(sslConfig.getKeystoreType())) {
+ if (StringUtils.isNotBlank(sslConfig.getKeystoreType())) {
sslContextFactory.setKeyStoreType(sslConfig.getKeystoreType());
}
- if (!StringUtils.isBlank(sslConfig.getKeystorePassword())) {
+ if (StringUtils.isNotBlank(sslConfig.getKeystorePassword())) {
sslContextFactory.setKeyStorePassword(sslConfig.getKeystorePassword());
}
- if (!StringUtils.isBlank(sslConfig.getTruststore())) {
+ if (StringUtils.isNotBlank(sslConfig.getTruststore())) {
sslContextFactory.setTrustStorePath(sslConfig.getTruststore());
}
- if (!StringUtils.isBlank(sslConfig.getTruststorePassword())) {
+ if (StringUtils.isNotBlank(sslConfig.getTruststorePassword())) {
sslContextFactory.setTrustStorePassword(sslConfig.getTruststorePassword());
}
@@ -131,7 +130,7 @@ public class JettyHelper {
jettyServer.setConnectors(new Connector[] {connector});
- if (!StringUtils.isBlank(bindAddress)) {
+ if (StringUtils.isNotBlank(bindAddress)) {
connector.setHost(bindAddress);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
index bf0b99c..3e6e4484 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
@@ -14,6 +14,32 @@
*/
package org.apache.geode.management.internal;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.GemFireConfigException;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.net.SSLConfigurationFactory;
+import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.internal.net.SocketCreatorFactory;
+import org.apache.geode.internal.security.SecurableCommunicationChannel;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
+import org.apache.geode.internal.tcp.TCPConduit;
+import org.apache.geode.management.ManagementException;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.ManagerMXBean;
+import org.apache.geode.management.internal.security.AccessControlMBean;
+import org.apache.geode.management.internal.security.MBeanServerWrapper;
+import org.apache.geode.management.internal.security.ResourceConstants;
+import org.apache.geode.management.internal.unsafe.ReadOpFileAccessController;
+import org.apache.logging.log4j.Logger;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+
import java.io.IOException;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
@@ -29,7 +55,6 @@ import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Set;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
@@ -43,33 +68,6 @@ import javax.management.remote.rmi.RMIJRMPServerImpl;
import javax.management.remote.rmi.RMIServerImpl;
import javax.rmi.ssl.SslRMIClientSocketFactory;
-import org.apache.logging.log4j.Logger;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-
-import org.apache.geode.GemFireConfigException;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.net.SSLConfigurationFactory;
-import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.internal.net.SocketCreatorFactory;
-import org.apache.geode.internal.security.SecurableCommunicationChannel;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
-import org.apache.geode.internal.tcp.TCPConduit;
-import org.apache.geode.management.ManagementException;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.ManagerMXBean;
-import org.apache.geode.management.internal.security.AccessControlMBean;
-import org.apache.geode.management.internal.security.MBeanServerWrapper;
-import org.apache.geode.management.internal.security.ResourceConstants;
-import org.apache.geode.management.internal.unsafe.ReadOpFileAccessController;
-
/**
* Agent implementation that controls the JMX server end points for JMX clients to connect, such as
* an RMI server.
@@ -317,9 +315,9 @@ public class ManagementAgent {
}
private String getHost(final String bindAddress) throws UnknownHostException {
- if (!StringUtils.isBlank(this.config.getJmxManagerHostnameForClients())) {
+ if (StringUtils.isNotBlank(this.config.getJmxManagerHostnameForClients())) {
return this.config.getJmxManagerHostnameForClients();
- } else if (!StringUtils.isBlank(bindAddress)) {
+ } else if (StringUtils.isNotBlank(bindAddress)) {
return InetAddress.getByName(bindAddress).getHostAddress();
} else {
return SocketCreator.getLocalHost().getHostAddress();
@@ -376,7 +374,7 @@ public class ManagementAgent {
}
String jmxManagerHostnameForClients = this.config.getJmxManagerHostnameForClients();
- if (!StringUtils.isBlank(jmxManagerHostnameForClients)) {
+ if (StringUtils.isNotBlank(jmxManagerHostnameForClients)) {
System.setProperty("java.rmi.server.hostname", jmxManagerHostnameForClients);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/RestAgent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/RestAgent.java b/geode-core/src/main/java/org/apache/geode/management/internal/RestAgent.java
index 837e815..7c9256d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/RestAgent.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/RestAgent.java
@@ -14,13 +14,7 @@
*/
package org.apache.geode.management.internal;
-import java.net.UnknownHostException;
-
import org.apache.commons.lang.StringUtils;
-import org.apache.logging.log4j.Logger;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.DataPolicy;
@@ -29,12 +23,17 @@ import org.apache.geode.cache.Scope;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.GemFireVersion;
import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.net.SSLConfigurationFactory;
-import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.cache.InternalRegionArguments;
import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.net.SSLConfigurationFactory;
+import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.security.SecurableCommunicationChannel;
import org.apache.geode.management.ManagementService;
+import org.apache.logging.log4j.Logger;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+
+import java.net.UnknownHostException;
/**
* Agent implementation that controls the HTTP server end points used for REST clients to connect
@@ -156,15 +155,15 @@ public class RestAgent {
public static String getBindAddressForHttpService(DistributionConfig config) {
String bindAddress = config.getHttpServiceBindAddress();
- if (!StringUtils.isBlank(bindAddress))
+ if (StringUtils.isNotBlank(bindAddress))
return bindAddress;
bindAddress = config.getServerBindAddress();
- if (!StringUtils.isBlank(bindAddress))
+ if (StringUtils.isNotBlank(bindAddress))
return bindAddress;
bindAddress = config.getBindAddress();
- if (!StringUtils.isBlank(bindAddress))
+ if (StringUtils.isNotBlank(bindAddress))
return bindAddress;
try {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/SSLUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/SSLUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/SSLUtil.java
index 1b39b73..820e8a5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/SSLUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/SSLUtil.java
@@ -14,15 +14,14 @@
*/
package org.apache.geode.management.internal;
+import org.apache.commons.lang.StringUtils;
+
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
-
import javax.net.ssl.SSLContext;
-import org.apache.geode.internal.lang.StringUtils;
-
/**
*
* @since GemFire 8.1
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
index ef643ac..770695a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
@@ -14,34 +14,7 @@
*/
package org.apache.geode.management.internal.beans;
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.admin.internal.BackupDataStoreHelper;
import org.apache.geode.admin.internal.BackupDataStoreResult;
import org.apache.geode.cache.persistence.PersistentID;
@@ -89,6 +62,32 @@ import org.apache.geode.management.internal.beans.stats.GatewaySenderClusterStat
import org.apache.geode.management.internal.beans.stats.MemberClusterStatsMonitor;
import org.apache.geode.management.internal.beans.stats.ServerClusterStatsMonitor;
import org.apache.geode.management.internal.cli.json.TypedJson;
+import org.apache.logging.log4j.Logger;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
/**
* This is the gateway to distributed system as a whole. Aggregated metrics and stats are shown
@@ -134,12 +133,12 @@ public class DistributedSystemBridge {
private volatile int serverSetSize;
/**
- * Gatway Sender Proxy set size
+ * Gateway Sender Proxy set size
*/
private volatile int gatewaySenderSetSize;
/**
- * Gatway Receiver Proxy set size
+ * Gateway Receiver Proxy set size
*/
private volatile int gatewayReceiverSetSize;
@@ -238,12 +237,12 @@ public class DistributedSystemBridge {
* @param service Management service
*/
public DistributedSystemBridge(SystemManagementService service) {
- this.distrLockServiceMap = new ConcurrentHashMap<ObjectName, DistributedLockServiceBridge>();
- this.distrRegionMap = new ConcurrentHashMap<ObjectName, DistributedRegionBridge>();
- this.mapOfMembers = new ConcurrentHashMap<ObjectName, MemberMXBean>();
- this.mapOfServers = new ConcurrentHashMap<ObjectName, CacheServerMXBean>();
- this.mapOfGatewayReceivers = new ConcurrentHashMap<ObjectName, GatewayReceiverMXBean>();
- this.mapOfGatewaySenders = new ConcurrentHashMap<ObjectName, GatewaySenderMXBean>();
+ this.distrLockServiceMap = new ConcurrentHashMap<>();
+ this.distrRegionMap = new ConcurrentHashMap<>();
+ this.mapOfMembers = new ConcurrentHashMap<>();
+ this.mapOfServers = new ConcurrentHashMap<>();
+ this.mapOfGatewayReceivers = new ConcurrentHashMap<>();
+ this.mapOfGatewaySenders = new ConcurrentHashMap<>();
this.service = service;
this.cache = GemFireCacheImpl.getInstance();
this.system = cache.getInternalDistributedSystem();
@@ -506,7 +505,7 @@ public class DistributedSystemBridge {
Iterator<DistributedMember> it = result.getSuccessfulMembers().keySet().iterator();
- Map<String, String[]> backedUpDiskStores = new HashMap<String, String[]>();
+ Map<String, String[]> backedUpDiskStores = new HashMap<>();
while (it.hasNext()) {
DistributedMember member = it.next();
Set<PersistentID> setOfDisk = result.getSuccessfulMembers().get(member);
@@ -573,7 +572,7 @@ public class DistributedSystemBridge {
Iterator<GatewayReceiverMXBean> gatewayReceiverIterator =
mapOfGatewayReceivers.values().iterator();
if (gatewayReceiverIterator != null) {
- List<String> listOfReceivers = new ArrayList<String>();
+ List<String> listOfReceivers = new ArrayList<>();
while (gatewayReceiverIterator.hasNext()) {
listOfReceivers.add(gatewayReceiverIterator.next().getBindAddress());
}
@@ -606,7 +605,7 @@ public class DistributedSystemBridge {
Iterator<MemberMXBean> memberIterator = mapOfMembers.values().iterator();
if (memberIterator != null) {
- List<String> listOfServer = new ArrayList<String>();
+ List<String> listOfServer = new ArrayList<>();
while (memberIterator.hasNext()) {
MemberMXBean bean = memberIterator.next();
if (bean.isCacheServer()) {
@@ -626,7 +625,7 @@ public class DistributedSystemBridge {
Iterator<MemberMXBean> memberIterator = mapOfMembers.values().iterator();
if (memberIterator != null) {
- List<String> listOfServer = new ArrayList<String>();
+ List<String> listOfServer = new ArrayList<>();
while (memberIterator.hasNext()) {
MemberMXBean bean = memberIterator.next();
if (bean.isServer()) {
@@ -657,10 +656,10 @@ public class DistributedSystemBridge {
/**
* @return a list of Gateway Senders
*/
- public String[] listGatwaySenders() {
+ public String[] listGatewaySenders() {
Iterator<GatewaySenderMXBean> gatewaySenderIterator = mapOfGatewaySenders.values().iterator();
if (gatewaySenderIterator != null) {
- List<String> listOfSenders = new ArrayList<String>();
+ List<String> listOfSenders = new ArrayList<>();
while (gatewaySenderIterator.hasNext()) {
listOfSenders.add(gatewaySenderIterator.next().getSenderId());
}
@@ -709,18 +708,15 @@ public class DistributedSystemBridge {
public String[] listLocators() {
if (cache != null) {
// each locator is a string of the form host[port] or bind-addr[port]
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
Map<InternalDistributedMember, Collection<String>> map =
cache.getDistributionManager().getAllHostedLocators();
for (Collection<String> hostedLocators : map.values()) {
- for (String locator : hostedLocators) {
- set.add(locator);
- }
+ set.addAll(hostedLocators);
}
- String[] locators = set.toArray(new String[set.size()]);
- return locators;
+ return set.toArray(new String[set.size()]);
}
return ManagementConstants.NO_DATA_STRING;
}
@@ -755,7 +751,7 @@ public class DistributedSystemBridge {
Iterator<MemberMXBean> memberIterator = mapOfMembers.values().iterator();
if (memberIterator != null) {
- Map<String, String[]> mapOfDisks = new HashMap<String, String[]>();
+ Map<String, String[]> mapOfDisks = new HashMap<>();
while (memberIterator.hasNext()) {
MemberMXBean bean = memberIterator.next();
mapOfDisks.put(bean.getMember(), bean.getDiskStores());
@@ -803,7 +799,7 @@ public class DistributedSystemBridge {
Iterator<MemberMXBean> memberIterator = mapOfMembers.values().iterator();
if (memberIterator != null) {
- Set<String> locatorMemberSet = new TreeSet<String>();
+ Set<String> locatorMemberSet = new TreeSet<>();
while (memberIterator.hasNext()) {
MemberMXBean memberMxBean = memberIterator.next();
if (memberMxBean.isLocator()) {
@@ -822,17 +818,17 @@ public class DistributedSystemBridge {
private String[] listStandAloneLocatorMembers() {
String[] locatorMembers = ManagementConstants.NO_DATA_STRING;
- Set<DistributedMember> members = new HashSet<DistributedMember>();
+ Set<DistributedMember> members = new HashSet<>();
members.add(system.getDistributedMember());
members.addAll(system.getAllOtherMembers());
if (!members.isEmpty()) {
- Set<String> locatorMemberSet = new TreeSet<String>();
+ Set<String> locatorMemberSet = new TreeSet<>();
for (DistributedMember member : members) {
if (DistributionManager.LOCATOR_DM_TYPE == ((InternalDistributedMember) member)
.getVmKind()) {
String name = member.getName();
- name = name != null && !name.trim().isEmpty() ? name : member.getId();
+ name = StringUtils.isNotBlank(name) ? name : member.getId();
locatorMemberSet.add(name);
}
}
@@ -852,7 +848,7 @@ public class DistributedSystemBridge {
Collection<MemberMXBean> values = mapOfMembers.values();
if (values != null) {
- Set<String> groupSet = new TreeSet<String>();
+ Set<String> groupSet = new TreeSet<>();
for (MemberMXBean memberMXBean : values) {
String[] memberGroups = memberMXBean.getGroups();
if (memberGroups != null && memberGroups.length != 0) {
@@ -878,7 +874,7 @@ public class DistributedSystemBridge {
/**
* @param member name or id of the member
- * @return basic Opertaing metrics for a given member.
+ * @return basic Operating metrics for a given member.
*/
public OSMetrics showOSMetrics(String member) throws Exception {
MemberMXBean bean = validateMember(member);
@@ -911,7 +907,7 @@ public class DistributedSystemBridge {
return ManagementConstants.NO_DATA_STRING;
}
// Sort region paths
- SortedSet<String> regionPathsSet = new TreeSet<String>();
+ SortedSet<String> regionPathsSet = new TreeSet<>();
for (DistributedRegionBridge bridge : distrRegionMap.values()) {
regionPathsSet.add(bridge.getFullPath());
}
@@ -933,9 +929,8 @@ public class DistributedSystemBridge {
Set<InternalDistributedMember> members = ShutdownAllRequest.send(dm, 0);
String[] shutDownMembers = new String[members.size()];
int j = 0;
- Iterator<InternalDistributedMember> it = members.iterator();
- while (it.hasNext()) {
- shutDownMembers[j] = it.next().getId();
+ for (InternalDistributedMember member : members) {
+ shutDownMembers[j] = member.getId();
j++;
}
return shutDownMembers;
@@ -949,16 +944,16 @@ public class DistributedSystemBridge {
* replicated region member are up and running so that the recovered data from the disk will be in
* sync;
*
- * @return Array of PeristentMemberDetails (which contains host, directory and disk store id)
+ * @return Array of PersistentMemberDetails (which contains host, directory and disk store id)
*/
public PersistentMemberDetails[] listMissingDiskStores() {
PersistentMemberDetails[] missingDiskStores = null;
- Set<PersistentID> persitentMemberSet = MissingPersistentIDsRequest.send(dm);
- if (persitentMemberSet != null && persitentMemberSet.size() > 0) {
- missingDiskStores = new PersistentMemberDetails[persitentMemberSet.size()];
+ Set<PersistentID> persistentMemberSet = MissingPersistentIDsRequest.send(dm);
+ if (persistentMemberSet != null && persistentMemberSet.size() > 0) {
+ missingDiskStores = new PersistentMemberDetails[persistentMemberSet.size()];
int j = 0;
- for (PersistentID id : persitentMemberSet) {
+ for (PersistentID id : persistentMemberSet) {
missingDiskStores[j] = new PersistentMemberDetails(id.getHost().getCanonicalHostName(),
id.getDirectory(), id.getUUID().toString());
j++;
@@ -974,7 +969,7 @@ public class DistributedSystemBridge {
* @param diskStoreId UUID of the disk store to revoke
* @return successful or failure
*/
- public boolean revokeMissingDiskStores(final String diskStoreId) throws Exception {
+ public boolean revokeMissingDiskStores(final String diskStoreId) {
// make sure that the disk store we're revoking is actually missing
boolean found = false;
PersistentMemberDetails[] details = listMissingDiskStores();
@@ -1018,8 +1013,7 @@ public class DistributedSystemBridge {
public ObjectName fetchMemberObjectName(String member) throws Exception {
validateMember(member);
- ObjectName memberName = MBeanJMXAdapter.getMemberMBeanName(member);
- return memberName;
+ return MBeanJMXAdapter.getMemberMBeanName(member);
}
public ObjectName[] listMemberObjectNames() {
@@ -1062,7 +1056,7 @@ public class DistributedSystemBridge {
}
public ObjectName[] fetchRegionObjectNames(ObjectName memberMBeanName) throws Exception {
- List<ObjectName> list = new ArrayList<ObjectName>();
+ List<ObjectName> list = new ArrayList<>();
if (mapOfMembers.get(memberMBeanName) != null) {
MemberMXBean bean = mapOfMembers.get(memberMBeanName);
String member =
@@ -1080,11 +1074,8 @@ public class DistributedSystemBridge {
}
public ObjectName[] listDistributedRegionObjectNames() {
- List<ObjectName> list = new ArrayList<ObjectName>();
- Iterator<ObjectName> it = distrRegionMap.keySet().iterator();
- while (it.hasNext()) {
- list.add(it.next());
- }
+ List<ObjectName> list = new ArrayList<>();
+ list.addAll(distrRegionMap.keySet());
ObjectName[] objNames = new ObjectName[list.size()];
return list.toArray(objNames);
}
@@ -1127,8 +1118,7 @@ public class DistributedSystemBridge {
public ObjectName fetchDistributedLockServiceObjectName(String lockServiceName) throws Exception {
DistributedLockServiceMXBean bean = service.getDistributedLockServiceMXBean(lockServiceName);
if (bean != null) {
- ObjectName lockSerName = service.getDistributedLockServiceMBeanName(lockServiceName);
- return lockSerName;
+ return service.getDistributedLockServiceMBeanName(lockServiceName);
} else {
throw new Exception(
ManagementStrings.DISTRIBUTED_LOCK_SERVICE_MBEAN_NOT_FOUND_IN_SYSTEM.toString());
@@ -1217,7 +1207,7 @@ public class DistributedSystemBridge {
Set<ObjectName> mbeanSet = service.queryMBeanNames(distributedMember);
if (mbeanSet != null && mbeanSet.size() > 0) {
- listName = new ArrayList<ObjectName>();
+ listName = new ArrayList<>();
for (ObjectName name : mbeanSet) {
if (pattern.apply(name)) {
listName.add(name);
@@ -1226,8 +1216,8 @@ public class DistributedSystemBridge {
}
if (listName != null && listName.size() > 0) {
- ObjectName[] arry = new ObjectName[listName.size()];
- return listName.toArray(arry);
+ ObjectName[] array = new ObjectName[listName.size()];
+ return listName.toArray(array);
}
return ManagementConstants.NO_DATA_OBJECTNAME;
}
@@ -1240,21 +1230,18 @@ public class DistributedSystemBridge {
*/
public int getNumClients() {
if (mapOfServers.keySet().size() > 0) {
- Set<String> uniqueClientSet = new HashSet<String>();
- Iterator<CacheServerMXBean> it = mapOfServers.values().iterator();
- while (it.hasNext()) {
- String[] clients = null;
+ Set<String> uniqueClientSet = new HashSet<>();
+ for (CacheServerMXBean cacheServerMXBean : mapOfServers.values()) {
+ String[] clients;
try {
- clients = it.next().getClientIds();
+ clients = cacheServerMXBean.getClientIds();
} catch (Exception e) {
// Mostly due to condition where member is departed and proxy is still
// with Manager.
clients = null;
}
if (clients != null) {
- for (String client : clients) {
- uniqueClientSet.add(client);
- }
+ Collections.addAll(uniqueClientSet, clients);
}
}
return uniqueClientSet.size();
@@ -1477,10 +1464,8 @@ public class DistributedSystemBridge {
public Map<String, Boolean> viewRemoteClusterStatus() {
if (mapOfGatewaySenders.values().size() > 0) {
- Map<String, Boolean> senderMap = new HashMap<String, Boolean>();
- Iterator<GatewaySenderMXBean> it = mapOfGatewaySenders.values().iterator();
- while (it.hasNext()) {
- GatewaySenderMXBean bean = it.next();
+ Map<String, Boolean> senderMap = new HashMap<>();
+ for (GatewaySenderMXBean bean : mapOfGatewaySenders.values()) {
Integer dsId = bean.getRemoteDSId();
if (dsId != null) {
senderMap.merge(dsId.toString(), bean.isRunning(), Boolean::logicalAnd);
@@ -1548,10 +1533,10 @@ public class DistributedSystemBridge {
synchronized (distrRegionMap) {
DistributedRegionBridge bridge = distrRegionMap.get(distributedRegionObjectName);
if (bridge != null) {
- FederationComponent newObj = (FederationComponent) (fedComp);
+ FederationComponent newObj = fedComp;
bridge.addProxyToMap(proxyName, regionProxy, newObj);
} else {
- FederationComponent newObj = (FederationComponent) (fedComp);
+ FederationComponent newObj = fedComp;
bridge = new DistributedRegionBridge(proxyName, regionProxy, newObj);
DistributedRegionMXBean mbean = new DistributedRegionMBean(bridge);
@@ -1591,10 +1576,10 @@ public class DistributedSystemBridge {
DistributedRegionBridge bridge = distrRegionMap.get(distributedRegionObjectName);
if (bridge != null) {
- FederationComponent newProxy = (FederationComponent) (newValue);
+ FederationComponent newProxy = newValue;
FederationComponent oldProxy = null;
if (oldValue != null) {
- oldProxy = (FederationComponent) oldValue;
+ oldProxy = oldValue;
}
bridge.updateRegion(newProxy, oldProxy);
}
@@ -1651,7 +1636,7 @@ public class DistributedSystemBridge {
FederationComponent newValue) {
// No body is calling this method right now.
// If aggregate stats are added in Distributed Lock Service it will be
- // neeeded.
+ // needed.
}
public void memberDeparted(InternalDistributedMember id, boolean crashed) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
index a87b366..c45da73 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
@@ -14,11 +14,6 @@
*/
package org.apache.geode.management.internal.beans;
-import java.util.Map;
-
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.ObjectName;
-
import org.apache.geode.management.DiskBackupStatus;
import org.apache.geode.management.DiskMetrics;
import org.apache.geode.management.DistributedSystemMXBean;
@@ -28,6 +23,10 @@ import org.apache.geode.management.NetworkMetrics;
import org.apache.geode.management.OSMetrics;
import org.apache.geode.management.PersistentMemberDetails;
+import java.util.Map;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ObjectName;
+
/**
* Distributed System MBean
*
@@ -103,7 +102,7 @@ public class DistributedSystemMBean extends NotificationBroadcasterSupport
@Override
public String[] listGatewaySenders() {
- return bridge.listGatwaySenders();
+ return bridge.listGatewaySenders();
}
@Override
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
index 7dce602..003a8f3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
@@ -14,26 +14,7 @@
*/
package org.apache.geode.management.internal.beans;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.internal.cache.CacheService;
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.DiskStore;
import org.apache.geode.cache.Region;
@@ -42,11 +23,13 @@ import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewaySender;
import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.DistributionManager;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.distributed.internal.locks.DLockService;
import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.ClassLoadUtil;
+import org.apache.geode.internal.cache.CacheService;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.LocalRegion;
import org.apache.geode.internal.cache.PartitionedRegionHelper;
@@ -75,6 +58,21 @@ import org.apache.geode.management.membership.ClientMembershipEvent;
import org.apache.geode.management.membership.ClientMembershipListener;
import org.apache.geode.management.membership.ClientMembershipListenerAdapter;
import org.apache.geode.pdx.internal.PeerTypeRegistration;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
/**
* Acts as an intermediate between MBean layer and Federation Layer. Handles all Call backs from
@@ -111,9 +109,9 @@ public class ManagementAdapter {
private MBeanAggregator aggregator;
- public static final List<Class> refreshOnInit = new ArrayList<Class>();
+ public static final List<Class> refreshOnInit = new ArrayList<>();
- public static final List<String> internalLocks = new ArrayList<String>();
+ public static final List<String> internalLocks = new ArrayList<>();
static {
refreshOnInit.add(RegionMXBean.class);
@@ -219,9 +217,7 @@ public class ManagementAdapter {
service.afterCreateProxy(memberObjectName, MemberMXBean.class, localMember, addedComp);
- Iterator<ObjectName> it = registeredMBeans.keySet().iterator();
- while (it.hasNext()) {
- ObjectName objectName = it.next();
+ for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
continue;
}
@@ -235,8 +231,8 @@ public class ManagementAdapter {
FederationComponent newObj = service.getLocalManager().getFedComponents().get(objectName);
- for (int i = 0; i < intfTyps.length; i++) {
- Class intfTyp = (Class) intfTyps[i];
+ for (Type intfTyp1 : intfTyps) {
+ Class intfTyp = (Class) intfTyp1;
service.afterCreateProxy(objectName, intfTyp, object, newObj);
}
@@ -265,12 +261,10 @@ public class ManagementAdapter {
MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
- ObjectName aggregatemMBeanPattern = null;
+ ObjectName aggregatemMBeanPattern;
try {
aggregatemMBeanPattern = new ObjectName(ManagementConstants.AGGREGATE_MBEAN_PATTERN);
- } catch (MalformedObjectNameException e1) {
- throw new ManagementException(e1);
- } catch (NullPointerException e1) {
+ } catch (MalformedObjectNameException | NullPointerException e1) {
throw new ManagementException(e1);
}
@@ -284,10 +278,7 @@ public class ManagementAdapter {
service.afterRemoveProxy(memberObjectName, MemberMXBean.class, localMember, removedComp);
- Iterator<ObjectName> it = registeredMBeans.keySet().iterator();
-
- while (it.hasNext()) {
- ObjectName objectName = it.next();
+ for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
continue;
}
@@ -304,14 +295,11 @@ public class ManagementAdapter {
FederationComponent oldObj = service.getLocalManager().getFedComponents().get(objectName);
- for (int i = 0; i < intfTyps.length; i++) {
- Class intfTyp = (Class) intfTyps[i];
+ for (Type intfTyp1 : intfTyps) {
+ Class intfTyp = (Class) intfTyp1;
service.afterRemoveProxy(objectName, intfTyp, object, oldObj);
}
- } catch (InstanceNotFoundException e) {
- logger.warn("Failed to invoke aggregator for {} with exception {}", objectName,
- e.getMessage(), e);
- } catch (ClassNotFoundException e) {
+ } catch (InstanceNotFoundException | ClassNotFoundException e) {
logger.warn("Failed to invoke aggregator for {} with exception {}", objectName,
e.getMessage(), e);
}
@@ -359,7 +347,7 @@ public class ManagementAdapter {
// Bridge is responsible for extracting data from GemFire Layer
RegionMBeanBridge<K, V> bridge = RegionMBeanBridge.getInstance(region);
- RegionMXBean regionMBean = new RegionMBean<K, V>(bridge);
+ RegionMXBean regionMBean = new RegionMBean<>(bridge);
ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(
internalCache.getDistributedSystem().getDistributedMember(), region.getFullPath());
ObjectName changedMBeanName = service.registerInternalMBean(regionMBean, regionMBeanName);
@@ -567,7 +555,7 @@ public class ManagementAdapter {
ObjectName asycnEventQueueMBeanName = MBeanJMXAdapter.getAsycnEventQueueMBeanName(
internalCache.getDistributedSystem().getDistributedMember(), queue.getId());
- AsyncEventQueueMBean bean = null;
+ AsyncEventQueueMBean bean;
try {
bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean(queue.getId());
if (bean == null) {
@@ -616,7 +604,7 @@ public class ManagementAdapter {
}
private Map<String, String> prepareUserData(AlertDetails details) {
- Map<String, String> userData = new HashMap<String, String>();
+ Map<String, String> userData = new HashMap<>();
userData.put(JMXNotificationUserData.ALERT_LEVEL,
AlertDetails.getAlertLevelAsString(details.getAlertLevel()));
@@ -627,7 +615,7 @@ public class ManagementAdapter {
String nameOrId = memberSource; // TODO: what if sender is null?
if (sender != null) {
nameOrId = sender.getName();
- nameOrId = nameOrId != null && !nameOrId.trim().isEmpty() ? nameOrId : sender.getId();
+ nameOrId = StringUtils.isNotBlank(nameOrId) ? nameOrId : sender.getId();
}
userData.put(JMXNotificationUserData.MEMBER, nameOrId);
@@ -799,7 +787,7 @@ public class ManagementAdapter {
synchronized (regionOpLock) {
ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(
internalCache.getDistributedSystem().getDistributedMember(), region.getFullPath());
- RegionMBean bean = null;
+ RegionMBean bean;
try {
bean = (RegionMBean) service.getLocalRegionMBean(region.getFullPath());
} catch (ManagementException e) {
@@ -838,7 +826,7 @@ public class ManagementAdapter {
ObjectName diskStoreMBeanName = MBeanJMXAdapter.getDiskStoreMBeanName(
internalCache.getDistributedSystem().getDistributedMember(), disk.getName());
- DiskStoreMBean bean = null;
+ DiskStoreMBean bean;
try {
bean = (DiskStoreMBean) service.getLocalDiskStoreMBean(disk.getName());
if (bean == null) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
index f701d29..9829df3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
@@ -14,21 +14,7 @@
*/
package org.apache.geode.management.internal.beans;
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.logging.log4j.Logger;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.SystemFailure;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.DataPolicy;
@@ -64,6 +50,19 @@ import org.apache.geode.management.internal.cli.commands.DataCommands;
import org.apache.geode.management.internal.cli.json.GfJsonException;
import org.apache.geode.management.internal.cli.json.GfJsonObject;
import org.apache.geode.management.internal.cli.json.TypedJson;
+import org.apache.logging.log4j.Logger;
+
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* This function is executed on one or multiple members based on the member input to
@@ -128,7 +127,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
final boolean showMember, final String regionName, final int limit,
final int queryResultSetLimit, final int queryCollectionsDepth) throws Exception {
InternalCache cache = getCache();
- Function loclQueryFunc = new LocalQueryFunction("LocalQueryFunction", regionName, showMember)
+ Function localQueryFunc = new LocalQueryFunction("LocalQueryFunction", regionName, showMember)
.setOptimizeForWrite(true);
queryString = applyLimitClause(queryString, limit, queryResultSetLimit);
@@ -154,7 +153,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
results = query.execute();
} else {
- ResultCollector rcollector = null;
+ ResultCollector rcollector;
PartitionedRegion parRegion =
PartitionedRegionHelper.getPartitionedRegion(regionName, cache);
@@ -169,13 +168,11 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
}
LocalDataSet lds = new LocalDataSet(parRegion, localPrimaryBucketSet);
DefaultQuery query = (DefaultQuery) cache.getQueryService().newQuery(queryString);
- SelectResults selectResults =
- (SelectResults) lds.executeQuery(query, null, localPrimaryBucketSet);
- results = selectResults;
+ results = (SelectResults) lds.executeQuery(query, null, localPrimaryBucketSet);
}
} else {
rcollector = FunctionService.onRegion(cache.getRegion(regionName))
- .setArguments(queryString).execute(loclQueryFunc);
+ .setArguments(queryString).execute(localQueryFunc);
results = rcollector.getResult();
}
}
@@ -183,8 +180,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
if (results != null && results instanceof SelectResults) {
SelectResults selectResults = (SelectResults) results;
- for (Iterator iter = selectResults.iterator(); iter.hasNext();) {
- Object object = iter.next();
+ for (Object object : selectResults) {
result.add(RESULT_KEY, object);
noDataFound = false;
}
@@ -203,7 +199,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
if (noDataFound) {
return new QueryDataFunctionResult(QUERY_EXEC_SUCCESS,
- BeanUtilFuncs.compress(new JsonisedErroMessage(NO_DATA_FOUND).toString()));
+ BeanUtilFuncs.compress(new JsonisedErrorMessage(NO_DATA_FOUND).toString()));
}
return new QueryDataFunctionResult(QUERY_EXEC_SUCCESS,
BeanUtilFuncs.compress(result.toString()));
@@ -272,7 +268,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
// member.
// Note , if no member is selected this is the code path executed. A
// random associated member is chosen.
- List<String> decompressedList = new ArrayList<String>();
+ List<String> decompressedList = new ArrayList<>();
decompressedList.add(BeanUtilFuncs.decompress(result.compressedBytes));
return wrapResult(decompressedList.toString());
}
@@ -290,10 +286,10 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
}
Iterator<QueryDataFunctionResult> it = list.iterator();
- List<String> decompressedList = new ArrayList<String>();
+ List<String> decompressedList = new ArrayList<>();
while (it.hasNext()) {
- String decompressedStr = null;
+ String decompressedStr;
decompressedStr = BeanUtilFuncs.decompress(it.next().compressedBytes);
decompressedList.add(decompressedStr);
}
@@ -308,12 +304,6 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
} catch (FunctionException fe) {
throw new Exception(
ManagementStrings.QUERY__MSG__QUERY_EXEC.toLocalizedString(fe.getMessage()));
- } catch (IOException e) {
- throw new Exception(
- ManagementStrings.QUERY__MSG__QUERY_EXEC.toLocalizedString(e.getMessage()));
- } catch (Exception e) {
- throw new Exception(
- ManagementStrings.QUERY__MSG__QUERY_EXEC.toLocalizedString(e.getMessage()));
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
@@ -339,20 +329,20 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
throws Exception {
if (query == null || query.isEmpty()) {
- return new JsonisedErroMessage(ManagementStrings.QUERY__MSG__QUERY_EMPTY.toLocalizedString())
+ return new JsonisedErrorMessage(ManagementStrings.QUERY__MSG__QUERY_EMPTY.toLocalizedString())
.toString();
}
Set<DistributedMember> inputMembers = null;
- if (members != null && !members.trim().isEmpty()) {
- inputMembers = new HashSet<DistributedMember>();
+ if (StringUtils.isNotBlank(members)) {
+ inputMembers = new HashSet<>();
StringTokenizer st = new StringTokenizer(members, ",");
while (st.hasMoreTokens()) {
String member = st.nextToken();
DistributedMember distributedMember = BeanUtilFuncs.getDistributedMemberByNameOrId(member);
inputMembers.add(distributedMember);
if (distributedMember == null) {
- return new JsonisedErroMessage(
+ return new JsonisedErrorMessage(
ManagementStrings.QUERY__MSG__INVALID_MEMBER.toLocalizedString(member)).toString();
}
}
@@ -370,7 +360,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
for (String regionPath : regionsInQuery) {
DistributedRegionMXBean regionMBean = service.getDistributedRegionMXBean(regionPath);
if (regionMBean == null) {
- return new JsonisedErroMessage(
+ return new JsonisedErrorMessage(
ManagementStrings.QUERY__MSG__REGIONS_NOT_FOUND.toLocalizedString(regionPath))
.toString();
} else {
@@ -379,7 +369,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
if (inputMembers != null && inputMembers.size() > 0) {
if (!associatedMembers.containsAll(inputMembers)) {
- return new JsonisedErroMessage(
+ return new JsonisedErrorMessage(
ManagementStrings.QUERY__MSG__REGIONS_NOT_FOUND_ON_MEMBERS
.toLocalizedString(regionPath)).toString();
}
@@ -387,7 +377,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
}
}
} else {
- return new JsonisedErroMessage(ManagementStrings.QUERY__MSG__INVALID_QUERY
+ return new JsonisedErrorMessage(ManagementStrings.QUERY__MSG__INVALID_QUERY
.toLocalizedString("Region mentioned in query probably missing /")).toString();
}
@@ -398,7 +388,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
if (regionMBean.getRegionType().equals(DataPolicy.PARTITION.toString())
|| regionMBean.getRegionType().equals(DataPolicy.PERSISTENT_PARTITION.toString())) {
- return new JsonisedErroMessage(
+ return new JsonisedErrorMessage(
ManagementStrings.QUERY__MSG__JOIN_OP_EX.toLocalizedString()).toString();
}
}
@@ -422,8 +412,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
functionArgs[LIMIT] = limit;
functionArgs[QUERY_RESULTSET_LIMIT] = queryResultSetLimit;
functionArgs[QUERY_COLLECTIONS_DEPTH] = queryCollectionsDepth;
- Object result = callFunction(functionArgs, inputMembers, zipResult);
- return result;
+ return callFunction(functionArgs, inputMembers, zipResult);
} else { // Query on any random member
functionArgs[DISPLAY_MEMBERWISE] = false;
functionArgs[QUERY] = query;
@@ -431,17 +420,16 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
functionArgs[LIMIT] = limit;
functionArgs[QUERY_RESULTSET_LIMIT] = queryResultSetLimit;
functionArgs[QUERY_COLLECTIONS_DEPTH] = queryCollectionsDepth;
- Object result = callFunction(functionArgs, associatedMembers, zipResult);
- return result;
+ return callFunction(functionArgs, associatedMembers, zipResult);
}
} else {
- return new JsonisedErroMessage(ManagementStrings.QUERY__MSG__REGIONS_NOT_FOUND
+ return new JsonisedErrorMessage(ManagementStrings.QUERY__MSG__REGIONS_NOT_FOUND
.toLocalizedString(regionsInQuery.toString())).toString();
}
} catch (QueryInvalidException qe) {
- return new JsonisedErroMessage(
+ return new JsonisedErrorMessage(
ManagementStrings.QUERY__MSG__INVALID_QUERY.toLocalizedString(qe.getMessage()))
.toString();
}
@@ -451,13 +439,13 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
return (InternalCache) CacheFactory.getAnyInstance();
}
- private static class JsonisedErroMessage {
+ private static class JsonisedErrorMessage {
private static String message = "message";
private GfJsonObject gFJsonObject = new GfJsonObject();
- public JsonisedErroMessage(final String errorMessage) throws Exception {
+ public JsonisedErrorMessage(final String errorMessage) throws Exception {
try {
gFJsonObject.put(message, errorMessage);
} catch (GfJsonException e) {
@@ -483,10 +471,10 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
private static Set<String> compileQuery(final InternalCache cache, final String query)
throws QueryInvalidException {
QCompiler compiler = new QCompiler();
- Set<String> regionsInQuery = null;
+ Set<String> regionsInQuery;
try {
CompiledValue compiledQuery = compiler.compileQuery(query);
- Set<String> regions = new HashSet<String>();
+ Set<String> regions = new HashSet<>();
compiledQuery.getRegionsInQuery(regions, null);
regionsInQuery = Collections.unmodifiableSet(regions);
return regionsInQuery;
[4/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index bd6d810..c63b10b 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -14,6 +14,30 @@
*/
package org.apache.geode.management.internal.cli;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.cache.CacheClosedException;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.ClassPathLoader;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.execute.AbstractExecution;
+import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.functions.MembersForRegionFunction;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResultException;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
@@ -42,30 +66,6 @@ import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
-import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.execute.AbstractExecution;
-import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.functions.MembersForRegionFunction;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-
/**
* This class contains utility methods used by classes used to build the Command Line Interface
* (CLI).
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
index ae44e24..26b903b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
@@ -14,13 +14,7 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.springframework.shell.core.CommandMarker;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.execute.Execution;
import org.apache.geode.cache.execute.Function;
@@ -29,13 +23,18 @@ import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.internal.ClusterConfigurationService;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.shell.Gfsh;
import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
+import org.springframework.shell.core.CommandMarker;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
/**
* The AbstractCommandsSupport class is an abstract base class encapsulating common functionality
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
index 5dfc1b8..ca2de76 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
@@ -23,6 +23,7 @@ import org.apache.geode.cache.execute.FunctionInvocationTargetException;
import org.apache.geode.cache.execute.ResultCollector;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.internal.logging.log4j.LogLevel;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.ConverterHint;
import org.apache.geode.management.cli.Result;
@@ -42,7 +43,6 @@ import org.apache.geode.management.internal.cli.result.ErrorResultData;
import org.apache.geode.management.internal.cli.result.InfoResultData;
import org.apache.geode.management.internal.cli.result.ResultBuilder;
import org.apache.geode.management.internal.cli.result.TabularResultData;
-import org.apache.geode.internal.logging.log4j.LogLevel;
import org.apache.geode.management.internal.configuration.domain.XmlEntity;
import org.apache.geode.management.internal.security.ResourceOperation;
import org.apache.geode.security.ResourcePermission.Operation;
@@ -56,8 +56,6 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -76,7 +74,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
new AlterRuntimeConfigFunction();
@CliCommand(value = {CliStrings.DESCRIBE_CONFIG}, help = CliStrings.DESCRIBE_CONFIG__HELP)
- @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result describeConfig(@CliOption(key = CliStrings.DESCRIBE_CONFIG__MEMBER,
optionContext = ConverterHint.ALL_MEMBER_IDNAME,
@@ -131,10 +129,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
SectionResultData cacheServerSection = crd.addSection();
cacheServerSection.setHeader("Cache-server attributes");
- Iterator<Map<String, String>> iters = cacheServerAttributesList.iterator();
-
- while (iters.hasNext()) {
- Map<String, String> cacheServerAttributes = iters.next();
+ for (Map<String, String> cacheServerAttributes : cacheServerAttributesList) {
addSubSection(cacheServerSection, cacheServerAttributes, "");
}
}
@@ -164,7 +159,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
SectionResultData section = crd.addSection();
section.setHeader(headerText);
section.addSeparator('.');
- Set<String> attributes = new TreeSet<String>(attrMap.keySet());
+ Set<String> attributes = new TreeSet<>(attrMap.keySet());
for (String attribute : attributes) {
String attributeValue = attrMap.get(attribute);
@@ -177,7 +172,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
String headerText) {
if (!attrMap.isEmpty()) {
SectionResultData subSection = section.addSection();
- Set<String> attributes = new TreeSet<String>(attrMap.keySet());
+ Set<String> attributes = new TreeSet<>(attrMap.keySet());
subSection.setHeader(headerText);
for (String attribute : attributes) {
@@ -262,16 +257,12 @@ public class ConfigCommands extends AbstractCommandsSupport {
optionContext = ConverterHint.MEMBERGROUP,
help = CliStrings.ALTER_RUNTIME_CONFIG__MEMBER__HELP) String group,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT__HELP) Integer archiveDiskSpaceLimit,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT__HELP) Integer archiveFileSizeLimit,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT__HELP) Integer logDiskSpaceLimit,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT__HELP) Integer logFileSizeLimit,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL},
optionContext = ConverterHint.LOG_LEVEL,
@@ -279,31 +270,24 @@ public class ConfigCommands extends AbstractCommandsSupport {
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE},
help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE__HELP) String statisticArchiveFile,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE__HELP) Integer statisticSampleRate,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED__HELP) Boolean statisticSamplingEnabled,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "false",
help = CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ__HELP) Boolean setCopyOnRead,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE__HELP) Integer lockLease,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__LOCK__TIMEOUT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__LOCK__TIMEOUT__HELP) Integer lockTimeout,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL__HELP) Integer messageSyncInterval,
@CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__SEARCH__TIMEOUT},
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_RUNTIME_CONFIG__SEARCH__TIMEOUT__HELP) Integer searchTimeout) {
- Map<String, String> runTimeDistributionConfigAttributes = new HashMap<String, String>();
- Map<String, String> rumTimeCacheAttributes = new HashMap<String, String>();
- Set<DistributedMember> targetMembers = new HashSet<DistributedMember>();
+ Map<String, String> runTimeDistributionConfigAttributes = new HashMap<>();
+ Map<String, String> rumTimeCacheAttributes = new HashMap<>();
+ Set<DistributedMember> targetMembers;
try {
@@ -381,7 +365,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
}
if (!runTimeDistributionConfigAttributes.isEmpty() || !rumTimeCacheAttributes.isEmpty()) {
- Map<String, String> allRunTimeAttributes = new HashMap<String, String>();
+ Map<String, String> allRunTimeAttributes = new HashMap<>();
allRunTimeAttributes.putAll(runTimeDistributionConfigAttributes);
allRunTimeAttributes.putAll(rumTimeCacheAttributes);
@@ -390,8 +374,8 @@ public class ConfigCommands extends AbstractCommandsSupport {
List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
CompositeResultData crd = ResultBuilder.createCompositeResultData();
TabularResultData tabularData = crd.addSection().addTable();
- Set<String> successfulMembers = new TreeSet<String>();
- Set<String> errorMessages = new TreeSet<String>();
+ Set<String> successfulMembers = new TreeSet<>();
+ Set<String> errorMessages = new TreeSet<>();
for (CliFunctionResult result : results) {
@@ -459,7 +443,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
Map<String, String> arguments = parseResult.getParamValueStrings();
// validate log level
String logLevel = arguments.get("log-level");
- if (!StringUtils.isBlank(logLevel) && (LogLevel.getLevel(logLevel) == null)) {
+ if (StringUtils.isNotBlank(logLevel) && (LogLevel.getLevel(logLevel) == null)) {
return ResultBuilder.createUserErrorResult("Invalid log level: " + logLevel);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index 5b0651e..b8ebc49 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -14,28 +14,7 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Pattern;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.LogWriter;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.ExpirationAttributes;
@@ -52,7 +31,6 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.security.IntegratedSecurityService;
import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.management.DistributedRegionMXBean;
@@ -83,14 +61,33 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
import org.apache.geode.management.internal.security.ResourceOperation;
import org.apache.geode.security.ResourcePermission.Operation;
import org.apache.geode.security.ResourcePermission.Resource;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
/**
* @since GemFire 7.0
*/
public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
- public static final Set<RegionShortcut> PERSISTENT_OVERFLOW_SHORTCUTS =
- new TreeSet<RegionShortcut>();
+ public static final Set<RegionShortcut> PERSISTENT_OVERFLOW_SHORTCUTS = new TreeSet<>();
private SecurityService securityService = IntegratedSecurityService.getSecurityService();
@@ -117,17 +114,13 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result createRegion(
@CliOption(key = CliStrings.CREATE_REGION__REGION, mandatory = true,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__REGION__HELP) String regionPath,
- @CliOption(key = CliStrings.CREATE_REGION__REGIONSHORTCUT, mandatory = false,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+ @CliOption(key = CliStrings.CREATE_REGION__REGIONSHORTCUT,
help = CliStrings.CREATE_REGION__REGIONSHORTCUT__HELP) RegionShortcut regionShortcut,
@CliOption(key = CliStrings.CREATE_REGION__USEATTRIBUTESFROM,
optionContext = ConverterHint.REGION_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__USEATTRIBUTESFROM__HELP) String useAttributesFrom,
@CliOption(key = CliStrings.CREATE_REGION__GROUP, optionContext = ConverterHint.MEMBERGROUP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__GROUP__HELP) String[] groups,
@CliOption(key = CliStrings.CREATE_REGION__SKIPIFEXISTS, unspecifiedDefaultValue = "true",
specifiedDefaultValue = "true",
@@ -145,44 +138,32 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
help = CliStrings.CREATE_REGION__CACHEWRITER__HELP) String cacheWriter,
@CliOption(key = CliStrings.CREATE_REGION__COLOCATEDWITH,
optionContext = ConverterHint.REGION_PATH,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__COLOCATEDWITH__HELP) String prColocatedWith,
@CliOption(key = CliStrings.CREATE_REGION__COMPRESSOR,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__COMPRESSOR__HELP) String compressor,
@CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYLEVEL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__CONCURRENCYLEVEL__HELP) Integer concurrencyLevel,
@CliOption(key = CliStrings.CREATE_REGION__DISKSTORE,
help = CliStrings.CREATE_REGION__DISKSTORE__HELP) String diskStore,
@CliOption(key = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION__HELP) Boolean enableAsyncConflation,
@CliOption(key = CliStrings.CREATE_REGION__CLONINGENABLED,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
@CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED__HELP) Boolean concurrencyChecksEnabled,
@CliOption(key = CliStrings.CREATE_REGION__MULTICASTENABLED,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__MULTICASTENABLED__HELP) Boolean mcastEnabled,
@CliOption(key = CliStrings.CREATE_REGION__STATISTICSENABLED,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__STATISTICSENABLED__HELP) Boolean statisticsEnabled,
@CliOption(key = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION__HELP) Boolean enableSubscriptionConflation,
@CliOption(key = CliStrings.CREATE_REGION__DISKSYNCHRONOUS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__DISKSYNCHRONOUS__HELP) Boolean diskSynchronous,
@CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
@CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
@CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
@CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION,
help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
@@ -191,45 +172,34 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
@CliOption(key = CliStrings.CREATE_REGION__KEYCONSTRAINT,
help = CliStrings.CREATE_REGION__KEYCONSTRAINT__HELP) String keyConstraint,
@CliOption(key = CliStrings.CREATE_REGION__LOCALMAXMEMORY,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__LOCALMAXMEMORY__HELP) Integer prLocalMaxMemory,
- @CliOption(key = CliStrings.CREATE_REGION__OFF_HEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- specifiedDefaultValue = "true",
+ @CliOption(key = CliStrings.CREATE_REGION__OFF_HEAP, specifiedDefaultValue = "true",
help = CliStrings.CREATE_REGION__OFF_HEAP__HELP) Boolean offHeap,
@CliOption(key = CliStrings.CREATE_REGION__PARTITION_RESOLVER,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__PARTITION_RESOLVER__HELP) String partitionResolver,
@CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
@CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION,
help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
@CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
@CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION,
help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
@CliOption(key = CliStrings.CREATE_REGION__RECOVERYDELAY,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__RECOVERYDELAY__HELP) Long prRecoveryDelay,
@CliOption(key = CliStrings.CREATE_REGION__REDUNDANTCOPIES,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__REDUNDANTCOPIES__HELP) Integer prRedundantCopies,
@CliOption(key = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY__HELP) Long prStartupRecoveryDelay,
@CliOption(key = CliStrings.CREATE_REGION__TOTALMAXMEMORY,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__TOTALMAXMEMORY__HELP) Long prTotalMaxMemory,
@CliOption(key = CliStrings.CREATE_REGION__TOTALNUMBUCKETS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.CREATE_REGION__TOTALNUMBUCKETS__HELP) Integer prTotalNumBuckets,
@CliOption(key = CliStrings.CREATE_REGION__VALUECONSTRAINT,
help = CliStrings.CREATE_REGION__VALUECONSTRAINT__HELP) String valueConstraint
// NOTICE: keep the region attributes params in alphabetical order
) {
- Result result = null;
+ Result result;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
try {
@@ -271,7 +241,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
regionExpirationTTLAction);
}
- RegionFunctionArgs regionFunctionArgs = null;
+ RegionFunctionArgs regionFunctionArgs;
if (useAttributesFrom != null) {
if (!regionExists(cache, useAttributesFrom)) {
throw new IllegalArgumentException(CliStrings.format(
@@ -330,7 +300,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
validateRegionFunctionArgs(cache, regionFunctionArgs);
- Set<DistributedMember> membersToCreateRegionOn = null;
+ Set<DistributedMember> membersToCreateRegionOn;
if (groups != null && groups.length != 0) {
membersToCreateRegionOn = CliUtil.getDistributedMembersByGroup(cache, groups);
// have only normal members from the group
@@ -370,10 +340,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
result = ResultBuilder.buildResult(tabularResultData);
verifyDistributedRegionMbean(cache, regionPath);
- } catch (IllegalArgumentException e) {
- LogWrapper.getInstance().info(e.getMessage());
- result = ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
LogWrapper.getInstance().info(e.getMessage());
result = ResultBuilder.createUserErrorResult(e.getMessage());
} catch (RuntimeException e) {
@@ -406,8 +373,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
} else {
Thread.sleep(2);
}
- } catch (Exception ex) {
- continue;
+ } catch (Exception ignored) {
}
}
return false;
@@ -417,64 +383,47 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
public Result alterRegion(
@CliOption(key = CliStrings.ALTER_REGION__REGION, mandatory = true,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_REGION__REGION__HELP) String regionPath,
@CliOption(key = CliStrings.ALTER_REGION__GROUP, optionContext = ConverterHint.MEMBERGROUP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.ALTER_REGION__GROUP__HELP) String[] groups,
@CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "-1",
+ specifiedDefaultValue = "-1",
help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
@CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "INVALIDATE",
help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
@CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "-1",
+ specifiedDefaultValue = "-1",
help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
@CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "INVALIDATE",
help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
@CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "-1",
+ specifiedDefaultValue = "-1",
help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
@CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "INVALIDATE",
help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
- @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "-1",
+ @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL, specifiedDefaultValue = "-1",
help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
@CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
specifiedDefaultValue = "INVALIDATE",
help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
- @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
+ @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER, specifiedDefaultValue = "",
help = CliStrings.ALTER_REGION__CACHELISTENER__HELP) String[] cacheListeners,
- @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- specifiedDefaultValue = "null",
+ @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "null",
help = CliStrings.ALTER_REGION__CACHELOADER__HELP) String cacheLoader,
- @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- specifiedDefaultValue = "null",
+ @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "null",
help = CliStrings.ALTER_REGION__CACHEWRITER__HELP) String cacheWriter,
- @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
+ @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, specifiedDefaultValue = "",
help = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,
- @CliOption(key = CliStrings.ALTER_REGION__GATEWAYSENDERID,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
+ @CliOption(key = CliStrings.ALTER_REGION__GATEWAYSENDERID, specifiedDefaultValue = "",
help = CliStrings.ALTER_REGION__GATEWAYSENDERID__HELP) String[] gatewaySenderIds,
- @CliOption(key = CliStrings.ALTER_REGION__CLONINGENABLED,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- specifiedDefaultValue = "false",
+ @CliOption(key = CliStrings.ALTER_REGION__CLONINGENABLED, specifiedDefaultValue = "false",
help = CliStrings.ALTER_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
- @CliOption(key = CliStrings.ALTER_REGION__EVICTIONMAX,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "0",
+ @CliOption(key = CliStrings.ALTER_REGION__EVICTIONMAX, specifiedDefaultValue = "0",
help = CliStrings.ALTER_REGION__EVICTIONMAX__HELP) Integer evictionMax) {
- Result result = null;
+ Result result;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
this.securityService.authorizeRegionManage(regionPath);
@@ -535,10 +484,10 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
regionExpirationTTLAction);
}
- cacheLoader = convertDefaultValue(cacheLoader, StringUtils.EMPTY_STRING);
- cacheWriter = convertDefaultValue(cacheWriter, StringUtils.EMPTY_STRING);
+ cacheLoader = convertDefaultValue(cacheLoader, StringUtils.EMPTY);
+ cacheWriter = convertDefaultValue(cacheWriter, StringUtils.EMPTY);
- RegionFunctionArgs regionFunctionArgs = null;
+ RegionFunctionArgs regionFunctionArgs;
regionFunctionArgs = new RegionFunctionArgs(regionPath, null, null, false, null, null, null,
entryIdle, entryTTL, regionIdle, regionTTL, null, null, null, null, cacheListeners,
cacheLoader, cacheWriter, asyncEventQueueIds, gatewaySenderIds, null, cloningEnabled,
@@ -599,10 +548,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
}
}
result = ResultBuilder.buildResult(tabularResultData);
- } catch (IllegalArgumentException e) {
- LogWrapper.getInstance().info(e.getMessage());
- result = ResultBuilder.createUserErrorResult(e.getMessage());
- } catch (IllegalStateException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
LogWrapper.getInstance().info(e.getMessage());
result = ResultBuilder.createUserErrorResult(e.getMessage());
} catch (RuntimeException e) {
@@ -624,8 +570,8 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
String[] allRegionPaths = dsMBean.listAllRegionPaths();
- for (int i = 0; i < allRegionPaths.length; i++) {
- if (allRegionPaths[i].equals(regionPath)) {
+ for (String allRegionPath : allRegionPaths) {
+ if (allRegionPath.equals(regionPath)) {
regionFound = true;
break;
}
@@ -635,7 +581,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
}
private void validateRegionPathAndParent(InternalCache cache, String regionPath) {
- if (regionPath == null || "".equals(regionPath)) {
+ if (StringUtils.isEmpty(regionPath)) {
throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
}
// If a region path indicates a sub-region, check whether the parent region exists
@@ -652,13 +598,13 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
private void validateGroups(InternalCache cache, String[] groups) {
if (groups != null && groups.length != 0) {
- Set<String> existingGroups = new HashSet<String>();
+ Set<String> existingGroups = new HashSet<>();
Set<DistributedMember> members = CliUtil.getAllNormalMembers(cache);
for (DistributedMember distributedMember : members) {
List<String> memberGroups = distributedMember.getGroups();
existingGroups.addAll(memberGroups);
}
- List<String> groupsList = new ArrayList<String>(Arrays.asList(groups));
+ List<String> groupsList = new ArrayList<>(Arrays.asList(groups));
groupsList.removeAll(existingGroups);
if (!groupsList.isEmpty()) {
@@ -800,8 +746,8 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
throw new IllegalArgumentException(
CliStrings.CREATE_REGION__MSG__NO_GATEWAYSENDERS_IN_THE_SYSTEM);
} else {
- List<String> gatewaySendersList = new ArrayList<String>(Arrays.asList(gatewaySenders));
- gatewaySenderIds = new HashSet<String>(gatewaySenderIds);
+ List<String> gatewaySendersList = new ArrayList<>(Arrays.asList(gatewaySenders));
+ gatewaySenderIds = new HashSet<>(gatewaySenderIds);
gatewaySenderIds.removeAll(gatewaySendersList);
if (!gatewaySenderIds.isEmpty()) {
throw new IllegalArgumentException(CliStrings.format(
@@ -874,14 +820,9 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
String compressorClassName = regionFunctionArgs.getCompressor();
Object compressor = null;
try {
- Class<?> compressorClass =
- (Class<?>) ClassPathLoader.getLatest().forName(compressorClassName);
+ Class<?> compressorClass = ClassPathLoader.getLatest().forName(compressorClassName);
compressor = compressorClass.newInstance();
- } catch (InstantiationException e) {
- compressorFailure = true;
- } catch (IllegalAccessException e) {
- compressorFailure = true;
- } catch (ClassNotFoundException e) {
+ } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
compressorFailure = true;
}
@@ -954,8 +895,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
List<?> resultsList = (List<?>) resultCollector.getResult();
if (resultsList != null && !resultsList.isEmpty()) {
- for (int i = 0; i < resultsList.size(); i++) {
- Object object = resultsList.get(i);
+ for (Object object : resultsList) {
if (object instanceof IllegalArgumentException) {
throw (IllegalArgumentException) object;
} else if (object instanceof Throwable) {
@@ -1024,7 +964,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
}
@CliCommand(value = {CliStrings.DESTROY_REGION}, help = CliStrings.DESTROY_REGION__HELP)
- @CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEODE_REGION)
+ @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result destroyRegion(
@CliOption(key = CliStrings.DESTROY_REGION__REGION, optionContext = ConverterHint.REGION_PATH,
@@ -1035,15 +975,14 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
.createInfoResult(CliStrings.DESTROY_REGION__MSG__SPECIFY_REGIONPATH_TO_DESTROY);
}
- if (regionPath.trim().isEmpty() || regionPath.equals(Region.SEPARATOR)) {
+ if (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
return ResultBuilder.createInfoResult(CliStrings.format(
CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID, new Object[] {regionPath}));
}
- Result result = null;
+ Result result;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
try {
- String message = "";
InternalCache cache = getCache();
ManagementService managementService = ManagementService.getExistingManagementService(cache);
String regionPathToUse = regionPath;
@@ -1061,18 +1000,18 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
new Object[] {regionPath, "jmx-manager-update-rate milliseconds"}));
}
- CliFunctionResult destroyRegionResult = null;
+ CliFunctionResult destroyRegionResult;
ResultCollector<?, ?> resultCollector =
CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, regionMembersList);
List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
- message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED,
+ String message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED,
new Object[] {regionPath, ""});
// Only if there is an error is this set to false
boolean isRegionDestroyed = true;
- for (int i = 0; i < resultsList.size(); i++) {
- destroyRegionResult = resultsList.get(i);
+ for (CliFunctionResult aResultsList : resultsList) {
+ destroyRegionResult = aResultsList;
if (destroyRegionResult.isSuccessful()) {
xmlEntity.set(destroyRegionResult.getXmlEntity());
} else if (destroyRegionResult.getThrowable() != null) {
@@ -1175,7 +1114,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
private Set<DistributedMember> getMembersByIds(InternalCache cache, Set<String> memberIds) {
Set<DistributedMember> foundMembers = Collections.emptySet();
if (memberIds != null && !memberIds.isEmpty()) {
- foundMembers = new HashSet<DistributedMember>();
+ foundMembers = new HashSet<>();
Set<DistributedMember> allNormalMembers = CliUtil.getAllNormalMembers(cache);
for (String memberId : memberIds) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
index dfd20a9..ea10182 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
@@ -14,30 +14,16 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static java.util.stream.Collectors.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toSet;
import org.apache.commons.io.FileUtils;
-import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.cache.execute.ResultCollector;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.internal.ClusterConfigurationService;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.Result;
@@ -58,6 +44,20 @@ import org.apache.geode.management.internal.configuration.utils.ZipUtils;
import org.apache.geode.management.internal.security.ResourceOperation;
import org.apache.geode.security.ResourcePermission.Operation;
import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Commands for the cluster configuration
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 9110a1a..a4ba64c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -145,11 +145,12 @@ public class IndexCommands extends AbstractCommandsSupport {
final TabularResultData indexData = ResultBuilder.createTabularResultData();
for (final IndexDetails indexDetails : indexDetailsList) {
- indexData.accumulate("Member Name", StringUtils.valueOf(indexDetails.getMemberName(), ""));
+ indexData.accumulate("Member Name",
+ StringUtils.defaultString(indexDetails.getMemberName()));
indexData.accumulate("Member ID", indexDetails.getMemberId());
indexData.accumulate("Region Path", indexDetails.getRegionPath());
indexData.accumulate("Name", indexDetails.getIndexName());
- indexData.accumulate("Type", StringUtils.valueOf(indexDetails.getIndexType(), ""));
+ indexData.accumulate("Type", StringUtils.defaultString(indexDetails.getIndexType()));
indexData.accumulate("Indexed Expression", indexDetails.getIndexedExpression());
indexData.accumulate("From Clause", indexDetails.getFromClause());
@@ -355,7 +356,7 @@ public class IndexCommands extends AbstractCommandsSupport {
// If a regionName is specified, then authorize data manage on the regionName, otherwise, it
// requires data manage permission on all regions
- if (!StringUtils.isBlank(regionPath)) {
+ if (StringUtils.isNotBlank(regionPath)) {
regionName = regionPath.startsWith("/") ? regionPath.substring(1) : regionPath;
this.securityService.authorizeRegionManage(regionName);
} else {
@@ -405,15 +406,15 @@ public class IndexCommands extends AbstractCommandsSupport {
if (!successfulMembers.isEmpty()) {
InfoResultData infoResult = ResultBuilder.createInfoResultData();
- if (!StringUtils.isBlank(indexName)) {
- if (!StringUtils.isBlank(regionPath)) {
+ if (StringUtils.isNotBlank(indexName)) {
+ if (StringUtils.isNotBlank(regionPath)) {
infoResult.addLine(CliStrings.format(CliStrings.DESTROY_INDEX__ON__REGION__SUCCESS__MSG,
indexName, regionPath));
} else {
infoResult.addLine(CliStrings.format(CliStrings.DESTROY_INDEX__SUCCESS__MSG, indexName));
}
} else {
- if (!StringUtils.isBlank(regionPath)) {
+ if (StringUtils.isNotBlank(regionPath)) {
infoResult.addLine(CliStrings
.format(CliStrings.DESTROY_INDEX__ON__REGION__ONLY__SUCCESS__MSG, regionPath));
} else {
@@ -431,7 +432,7 @@ public class IndexCommands extends AbstractCommandsSupport {
} else {
ErrorResultData erd = ResultBuilder.createErrorResultData();
- if (!StringUtils.isBlank(indexName)) {
+ if (StringUtils.isNotBlank(indexName)) {
erd.addLine(CliStrings.format(CliStrings.DESTROY_INDEX__FAILURE__MSG, indexName));
} else {
erd.addLine("Indexes could not be destroyed for following reasons");
@@ -668,27 +669,27 @@ public class IndexCommands extends AbstractCommandsSupport {
public String getNumberOfKeys() {
return (getIndexStatisticsDetails() != null
- ? StringUtils.valueOf(getIndexStatisticsDetails().getNumberOfKeys(), "") : "");
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfKeys()) : "");
}
public String getNumberOfUpdates() {
return (getIndexStatisticsDetails() != null
- ? StringUtils.valueOf(getIndexStatisticsDetails().getNumberOfUpdates(), "") : "");
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfUpdates()) : "");
}
public String getNumberOfValues() {
return (getIndexStatisticsDetails() != null
- ? StringUtils.valueOf(getIndexStatisticsDetails().getNumberOfValues(), "") : "");
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfValues()) : "");
}
public String getTotalUpdateTime() {
return (getIndexStatisticsDetails() != null
- ? StringUtils.valueOf(getIndexStatisticsDetails().getTotalUpdateTime(), "") : "");
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUpdateTime()) : "");
}
public String getTotalUses() {
return (getIndexStatisticsDetails() != null
- ? StringUtils.valueOf(getIndexStatisticsDetails().getTotalUses(), "") : "");
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUses()) : "");
}
}
[2/6] geode git commit: GEODE-1994: Overhaul of
internal.lang.StringUtils to extend and heavily use commons.lang.StringUtils
Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshConfig.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshConfig.java
index c35f420..3c368c5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshConfig.java
@@ -14,12 +14,12 @@
*/
package org.apache.geode.management.internal.cli.shell;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.internal.util.IOUtils;
+
import java.io.File;
import java.util.logging.Level;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.util.IOUtils;
-
/**
*
* @since GemFire 7.0
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
index 7c80e0d..2b39bed 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -16,6 +16,7 @@ package org.apache.geode.management.internal.cli.shell;
import static org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper.execCLISteps;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.CommandProcessingException;
@@ -101,10 +102,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
} catch (NotAuthorizedException e) {
result = ResultBuilder
.createGemFireUnAuthorizedErrorResult("Unauthorized. Reason: " + e.getMessage());
- } catch (JMXInvocationException e) {
- Gfsh.getCurrentInstance().logWarning(e.getMessage(), e);
- } catch (IllegalStateException e) {
- // Shouldn't occur - we are always using GfsParseResult
+ } catch (JMXInvocationException | IllegalStateException e) {
Gfsh.getCurrentInstance().logWarning(e.getMessage(), e);
} catch (CommandProcessingException e) {
Gfsh.getCurrentInstance().logWarning(e.getMessage(), null);
@@ -204,11 +202,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
try {
interceptor = (CliAroundInterceptor) ClassPathLoader.getLatest().forName(interceptorClass)
.newInstance();
- } catch (InstantiationException e) {
- shell.logWarning("Configuration error", e);
- } catch (IllegalAccessException e) {
- shell.logWarning("Configuration error", e);
- } catch (ClassNotFoundException e) {
+ } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
shell.logWarning("Configuration error", e);
}
if (interceptor != null) {
@@ -247,7 +241,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
+ "Please check manager logs for error.");
}
- // the response could be a string which is a json respresentation of the CommandResult object
+ // the response could be a string which is a json representation of the CommandResult object
// it can also be a Path to a temp file downloaded from the rest http request
if (response instanceof String) {
CommandResponse commandResponse =
@@ -259,7 +253,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
}
String debugInfo = commandResponse.getDebugInfo();
- if (debugInfo != null && !debugInfo.trim().isEmpty()) {
+ if (StringUtils.isNotBlank(debugInfo)) {
// TODO - Abhishek When debug is ON, log response in gfsh logs
// TODO - Abhishek handle \n better. Is it coming from GemFire formatter
debugInfo = debugInfo.replaceAll("\n\n\n", "\n");
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java
index e9d183e..7ae7c3b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java
@@ -17,8 +17,8 @@ package org.apache.geode.management.internal.cli.shell;
import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_PREFIX;
import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_PREFIX;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.util.ArrayUtils;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.management.DistributedSystemMXBean;
@@ -192,7 +192,7 @@ public class JmxOperationInvoker implements OperationInvoker {
URL gfSecurityPropertiesUrl = null;
// Case 1: User has specified gfSecurity properties file
- if (!StringUtils.isBlank(gfSecurityPropertiesPathToUse)) {
+ if (StringUtils.isNotBlank(gfSecurityPropertiesPathToUse)) {
// User specified gfSecurity properties doesn't exist
if (!IOUtils.isExistingPathname(gfSecurityPropertiesPathToUse)) {
gfshInstance
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/CommandStringBuilder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/CommandStringBuilder.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/CommandStringBuilder.java
index 4410fea..cfb8a24 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/CommandStringBuilder.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/CommandStringBuilder.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.management.internal.cli.util;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.internal.lang.SystemUtils;
import org.apache.geode.management.internal.cli.GfshParser;
@@ -59,7 +59,7 @@ public class CommandStringBuilder {
}
public CommandStringBuilder addOptionWithValueCheck(String option, String value) {
- if (!StringUtils.isBlank(value)) {
+ if (StringUtils.isNotBlank(value)) {
return addOption(option, value);
}
return this;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
index 0dbe7e5..00902a9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
@@ -14,6 +14,25 @@
*/
package org.apache.geode.management.internal.configuration.domain;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.InternalGemFireError;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.Assert;
+import org.apache.geode.internal.Version;
+import org.apache.geode.internal.VersionedDataSerializable;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.configuration.utils.XmlUtils;
+import org.apache.geode.management.internal.configuration.utils.XmlUtils.XPathContext;
+import org.apache.logging.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -24,32 +43,11 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.xpath.XPathExpressionException;
-import org.apache.geode.internal.Assert;
-import org.apache.geode.internal.Version;
-import org.apache.geode.internal.VersionedDataSerializable;
-import org.apache.logging.log4j.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.apache.geode.DataSerializer;
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.internal.cache.xmlcache.CacheXml;
-import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.configuration.utils.XmlUtils;
-import org.apache.geode.management.internal.configuration.utils.XmlUtils.XPathContext;
-
/****
* Domain class for defining a GemFire entity in XML.
*
@@ -156,13 +154,13 @@ public class XmlEntity implements VersionedDataSerializable {
StringBuffer sb = new StringBuffer();
sb.append("//").append(this.prefix).append(':').append(this.parentType);
- if (!StringUtils.isBlank(parentKey) && !StringUtils.isBlank(parentValue)) {
+ if (StringUtils.isNotBlank(parentKey) && StringUtils.isNotBlank(parentValue)) {
sb.append("[@").append(parentKey).append("='").append(parentValue).append("']");
}
sb.append("/").append(childPrefix).append(':').append(this.type);
- if (!StringUtils.isBlank(childKey) && !StringUtils.isBlank(childValue)) {
+ if (StringUtils.isNotBlank(childKey) && StringUtils.isNotBlank(childValue)) {
sb.append("[@").append(childKey).append("='").append(childValue).append("']");
}
this.searchString = sb.toString();
@@ -175,9 +173,9 @@ public class XmlEntity implements VersionedDataSerializable {
* @since GemFire 8.1
*/
private void init() {
- Assert.assertTrue(!StringUtils.isBlank(type));
- Assert.assertTrue(!StringUtils.isBlank(prefix));
- Assert.assertTrue(!StringUtils.isBlank(namespace));
+ Assert.assertTrue(StringUtils.isNotBlank(type));
+ Assert.assertTrue(StringUtils.isNotBlank(prefix));
+ Assert.assertTrue(StringUtils.isNotBlank(namespace));
Assert.assertTrue(attributes != null);
if (null == xmlDefinition) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
index 837d99e..ac5e99a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
@@ -14,18 +14,16 @@
*/
package org.apache.geode.management.internal.configuration.messages;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Set;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.Version;
-import org.apache.geode.internal.lang.StringUtils;
-
/***
* Request sent by a member to the locator requesting the shared configuration
*
@@ -50,7 +48,7 @@ public class ConfigurationRequest implements DataSerializableFixedID {
}
public void addGroups(String group) {
- if (!StringUtils.isBlank(group))
+ if (StringUtils.isNotBlank(group))
this.groups.add(group);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationResponse.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationResponse.java
index 3248c98..cb9951f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationResponse.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationResponse.java
@@ -14,6 +14,15 @@
*/
package org.apache.geode.management.internal.configuration.messages;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.InternalGemFireError;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.geode.management.internal.configuration.utils.XmlUtils;
+import org.xml.sax.SAXException;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -22,21 +31,10 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
-import org.xml.sax.SAXException;
-
-import org.apache.geode.DataSerializer;
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.Version;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
-import org.apache.geode.management.internal.configuration.utils.XmlUtils;
-
/***
* Response containing the configuration requested by the {@link ConfigurationRequest}
*/
@@ -127,7 +125,7 @@ public class ConfigurationResponse implements DataSerializableFixedID {
try {
String cacheXmlContent = config.getCacheXmlContent();
- if (!StringUtils.isBlank(cacheXmlContent)) {
+ if (StringUtils.isNotBlank(cacheXmlContent)) {
sb.append("\n" + XmlUtils.prettyXml(cacheXmlContent));
}
} catch (IOException | TransformerFactoryConfigurationError | TransformerException
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
index 218762c..f86b9a3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
@@ -14,12 +14,24 @@
*/
package org.apache.geode.management.internal.configuration.utils;
-import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION;
-import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_PREFIX;
import static javax.xml.XMLConstants.NULL_NS_URI;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION;
+import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_PREFIX;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.internal.cache.xmlcache.CacheXmlParser;
+import org.apache.geode.management.internal.configuration.domain.CacheElement;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
-import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
@@ -33,7 +45,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
-
import javax.xml.namespace.NamespaceContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -50,20 +61,6 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.apache.geode.internal.cache.xmlcache.CacheXml;
-import org.apache.geode.internal.cache.xmlcache.CacheXmlParser;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.management.internal.configuration.domain.CacheElement;
-import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-
public class XmlUtils {
/**
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
index 0b64a44..54c29f8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
@@ -15,36 +15,6 @@
package org.apache.geode.management.internal.web.controllers;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.management.ManagementFactory;
-import java.net.URI;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.context.request.WebRequest;
-import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
-
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.lang.StringUtils;
@@ -64,6 +34,34 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.management.internal.web.controllers.support.LoginHandlerInterceptor;
import org.apache.geode.management.internal.web.util.UriUtils;
import org.apache.geode.security.NotAuthorizedException;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.management.ManagementFactory;
+import java.net.URI;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
/**
* The AbstractCommandsController class is the abstract base class encapsulating common
@@ -251,7 +249,7 @@ public abstract class AbstractCommandsController {
* @see java.lang.String
*/
protected static boolean hasValue(final String value) {
- return !StringUtils.isBlank(value);
+ return StringUtils.isNotBlank(value);
}
/**
@@ -530,7 +528,7 @@ public abstract class AbstractCommandsController {
if (hasValue(optionValue)) {
final String optionValueString = (optionValue instanceof String[]
- ? StringUtils.concat((String[]) optionValue, StringUtils.COMMA_DELIMITER)
+ ? StringUtils.join((String[]) optionValue, StringUtils.COMMA_DELIMITER)
: String.valueOf(optionValue));
command.addOption(optionName, optionValueString);
} else if (request != null && request.getParameterMap().containsKey(optionName)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ConfigCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ConfigCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ConfigCommandsController.java
index f468c65..25d0cc3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ConfigCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ConfigCommandsController.java
@@ -14,9 +14,6 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import java.io.IOException;
-import java.util.concurrent.Callable;
-
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -30,6 +27,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.util.concurrent.Callable;
+
/**
* The ConfigCommandsController class implements GemFire Management REST API web service endpoints
* for the Gfsh Config Commands.
@@ -184,12 +184,12 @@ public class ConfigCommandsController extends AbstractMultiPartCommandsControlle
if (hasValue(groups)) {
command.addOption(CliStrings.EXPORT_CONFIG__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.EXPORT_CONFIG__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
if (hasValue(directory)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
index 3a8ed82..ce2ed54 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
@@ -215,12 +215,12 @@ public class DataCommandsController extends AbstractCommandsController {
if (hasValue(includedRegions)) {
command.addOption(CliStrings.REBALANCE__INCLUDEREGION,
- StringUtils.concat(includedRegions, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(includedRegions, StringUtils.COMMA_DELIMITER));
}
if (hasValue(excludedRegions)) {
command.addOption(CliStrings.REBALANCE__EXCLUDEREGION,
- StringUtils.concat(excludedRegions, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(excludedRegions, StringUtils.COMMA_DELIMITER));
}
command.addOption(CliStrings.REBALANCE__SIMULATE, String.valueOf(simulate));
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DeployCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DeployCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DeployCommandsController.java
index fe5be62..35f57ef 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DeployCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DeployCommandsController.java
@@ -14,13 +14,10 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import java.io.IOException;
-
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.management.internal.web.util.ConvertUtils;
-
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -28,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+
/**
* The DeployCommandsController class implements the GemFire Management REST API web service
* endpoints for the Gfsh Deploy Commands.
@@ -55,7 +54,7 @@ public class DeployCommandsController extends AbstractMultiPartCommandsControlle
if (hasValue(groups)) {
command.addOption(CliStrings.LIST_DEPLOYED__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -75,7 +74,7 @@ public class DeployCommandsController extends AbstractMultiPartCommandsControlle
if (hasValue(groups)) {
command.addOption(CliStrings.DEPLOY__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(jarFileName)) {
@@ -101,12 +100,12 @@ public class DeployCommandsController extends AbstractMultiPartCommandsControlle
if (hasValue(groups)) {
command.addOption(CliStrings.UNDEPLOY__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(jarFileNames)) {
command.addOption(CliStrings.UNDEPLOY__JAR,
- StringUtils.concat(jarFileNames, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(jarFileNames, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
index 661340c..fa074c3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
@@ -14,8 +14,6 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import java.util.concurrent.Callable;
-
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -27,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import java.util.concurrent.Callable;
+
/**
* The DiskStoreCommandsController class implements GemFire Management REST API web service
* endpoints for the Gfsh Disk Store Commands.
@@ -80,7 +80,7 @@ public class DiskStoreCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.COMPACT_DISK_STORE__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return getProcessCommandCallable(command.toString());
@@ -115,8 +115,10 @@ public class DiskStoreCommandsController extends AbstractCommandsController {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
command.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreNameId);
- command.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE,
- StringUtils.concat(directoryAndSizes, StringUtils.COMMA_DELIMITER));
+ if (hasValue(directoryAndSizes)) {
+ command.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE,
+ StringUtils.join(directoryAndSizes, StringUtils.COMMA_DELIMITER));
+ }
command.addOption(CliStrings.CREATE_DISK_STORE__ALLOW_FORCE_COMPACTION,
String.valueOf(Boolean.TRUE.equals(allowForceCompaction)));
command.addOption(CliStrings.CREATE_DISK_STORE__AUTO_COMPACT,
@@ -135,7 +137,7 @@ public class DiskStoreCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_DISK_STORE__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -163,7 +165,7 @@ public class DiskStoreCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.DESTROY_DISK_STORE__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DurableClientCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DurableClientCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DurableClientCommandsController.java
index 1d718b4..8f31f7a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DurableClientCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DurableClientCommandsController.java
@@ -19,7 +19,11 @@ import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
/**
* The DurableClientCommandsController class implements GemFire Management REST API web service
@@ -59,7 +63,7 @@ public class DurableClientCommandsController extends AbstractCommandsController
if (hasValue(groups)) {
command.addOption(CliStrings.LIST_DURABLE_CQS__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -109,7 +113,7 @@ public class DurableClientCommandsController extends AbstractCommandsController
if (hasValue(groups)) {
command.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -134,7 +138,7 @@ public class DurableClientCommandsController extends AbstractCommandsController
if (hasValue(groups)) {
command.addOption(CliStrings.CLOSE_DURABLE_CLIENTS__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -161,7 +165,7 @@ public class DurableClientCommandsController extends AbstractCommandsController
if (hasValue(groups)) {
command.addOption(CliStrings.CLOSE_DURABLE_CQS__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
index 604bdee..a369c6e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
@@ -64,7 +64,7 @@ public class ExportLogController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.EXPORT_LOGS__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(memberNameId)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/FunctionCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/FunctionCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/FunctionCommandsController.java
index 77cfb40..508c335 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/FunctionCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/FunctionCommandsController.java
@@ -14,8 +14,6 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import java.util.concurrent.Callable;
-
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -27,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import java.util.concurrent.Callable;
+
/**
* The FunctionCommandsController class implements GemFire Management REST API web service endpoints
* for the Gfsh Function Commands.
@@ -60,12 +60,12 @@ public class FunctionCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.LIST_FUNCTION__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.LIST_FUNCTION__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
if (hasValue(matches)) {
@@ -108,7 +108,7 @@ public class FunctionCommandsController extends AbstractCommandsController {
if (hasValue(arguments)) {
command.addOption(CliStrings.EXECUTE_FUNCTION__ARGUMENTS,
- StringUtils.concat(arguments, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(arguments, StringUtils.COMMA_DELIMITER));
}
if (hasValue(filter)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
index d19aee1..9b13b5f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
@@ -85,7 +85,7 @@ public class MiscellaneousCommandsController extends AbstractCommandsController
if (hasValue(groups)) {
command.addOption(CliStrings.GC__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -175,7 +175,7 @@ public class MiscellaneousCommandsController extends AbstractCommandsController
if (hasValue(categories)) {
command.addOption(CliStrings.SHOW_METRICS__CATEGORY,
- StringUtils.concat(categories, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(categories, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/PdxCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/PdxCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/PdxCommandsController.java
index c68ee35..c757fd3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/PdxCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/PdxCommandsController.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.web.controllers;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -72,12 +71,12 @@ public class PdxCommandsController extends AbstractCommandsController {
if (hasValue(autoSerializerClasses)) {
command.addOption(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES,
- StringUtils.concat(autoSerializerClasses, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(autoSerializerClasses, StringUtils.COMMA_DELIMITER));
}
if (hasValue(portableAutoSerializerClasses)) {
command.addOption(CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES,
- StringUtils.concat(portableAutoSerializerClasses, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(portableAutoSerializerClasses, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -97,7 +96,7 @@ public class PdxCommandsController extends AbstractCommandsController {
if (hasValue(diskDirs)) {
command.addOption(CliStrings.PDX_DISKDIR,
- StringUtils.concat(diskDirs, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(diskDirs, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -118,7 +117,7 @@ public class PdxCommandsController extends AbstractCommandsController {
if (hasValue(diskDirs)) {
command.addOption(CliStrings.PDX_DISKDIR,
- StringUtils.concat(diskDirs, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(diskDirs, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/QueueCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/QueueCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/QueueCommandsController.java
index 396726e..df49e49 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/QueueCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/QueueCommandsController.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.web.controllers;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -88,12 +87,12 @@ public class QueueCommandsController extends AbstractCommandsController {
if (hasValue(listenerParametersValues)) {
command.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE,
- StringUtils.concat(listenerParametersValues, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(listenerParametersValues, StringUtils.COMMA_DELIMITER));
}
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
command.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL,
@@ -138,7 +137,7 @@ public class QueueCommandsController extends AbstractCommandsController {
if (hasValue(gatewayEventFilters)) {
command.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER,
- StringUtils.concat(gatewayEventFilters, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(gatewayEventFilters, StringUtils.COMMA_DELIMITER));
}
if (hasValue(gatewaySubstitutionFilter)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
index e503e56..baf24e5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.web.controllers;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -116,7 +115,7 @@ public class RegionCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.ALTER_REGION__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
addCommandOption(request, command, CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME,
@@ -243,7 +242,7 @@ public class RegionCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_REGION__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
command.addOption(CliStrings.CREATE_REGION__SKIPIFEXISTS,
@@ -323,7 +322,7 @@ public class RegionCommandsController extends AbstractCommandsController {
if (hasValue(cacheListeners)) {
command.addOption(CliStrings.CREATE_REGION__CACHELISTENER,
- StringUtils.concat(cacheListeners, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(cacheListeners, StringUtils.COMMA_DELIMITER));
}
if (hasValue(cacheLoader)) {
@@ -336,12 +335,12 @@ public class RegionCommandsController extends AbstractCommandsController {
if (hasValue(asyncEventQueueIds)) {
command.addOption(CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID,
- StringUtils.concat(asyncEventQueueIds, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(asyncEventQueueIds, StringUtils.COMMA_DELIMITER));
}
if (hasValue(gatewaySenderIds)) {
command.addOption(CliStrings.CREATE_REGION__GATEWAYSENDERID,
- StringUtils.concat(gatewaySenderIds, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(gatewaySenderIds, StringUtils.COMMA_DELIMITER));
}
if (Boolean.TRUE.equals(enableConcurrencyChecks)) {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
index 0ecb77f..e983f2a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
@@ -14,14 +14,15 @@
*/
package org.apache.geode.management.internal.web.controllers;
-import java.io.IOException;
-import java.util.Set;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.lang.ObjectUtils;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.web.domain.Link;
+import org.apache.geode.management.internal.web.domain.LinkIndex;
+import org.apache.geode.management.internal.web.domain.QueryParameterSource;
+import org.apache.geode.management.internal.web.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -32,15 +33,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
-import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.web.domain.Link;
-import org.apache.geode.management.internal.web.domain.LinkIndex;
-import org.apache.geode.management.internal.web.domain.QueryParameterSource;
-import org.apache.geode.management.internal.web.http.HttpMethod;
+import java.io.IOException;
+import java.util.Set;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
/**
* The ShellCommandsController class implements GemFire REST API calls for Gfsh Shell Commands.
@@ -97,7 +95,7 @@ public class ShellCommandsController extends AbstractCommandsController {
@RequestParam("operationName") final String operationName,
@RequestParam(value = "signature", required = false) String[] signature,
@RequestParam(value = "parameters", required = false) Object[] parameters) {
- signature = (signature != null ? signature : StringUtils.EMPTY_STRING_ARRAY);
+ signature = (signature != null ? signature : ArrayUtils.EMPTY_STRING_ARRAY);
parameters = (parameters != null ? parameters : ObjectUtils.EMPTY_OBJECT_ARRAY);
try {
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
index fa5aa57..4fd4b96 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
@@ -18,7 +18,6 @@ package org.apache.geode.management.internal.web.controllers;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -54,12 +53,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.LIST_GATEWAY__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.LIST_GATEWAY__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -90,7 +89,7 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_GATEWAYRECEIVER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(manualStart)) {
@@ -100,7 +99,7 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(members)) {
command.addOption(CliStrings.CREATE_GATEWAYRECEIVER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
if (hasValue(startPort)) {
@@ -127,7 +126,7 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(gatewayTransportFilters)) {
command.addOption(CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER,
- StringUtils.concat(gatewayTransportFilters, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(gatewayTransportFilters, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -182,12 +181,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
if (hasValue(parallel)) {
@@ -257,12 +256,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(gatewayEventFilters)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER,
- StringUtils.concat(gatewayEventFilters, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(gatewayEventFilters, StringUtils.COMMA_DELIMITER));
}
if (hasValue(gatewayTransportFilters)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER,
- StringUtils.concat(gatewayTransportFilters, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(gatewayTransportFilters, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -281,12 +280,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.CREATE_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
}
@@ -318,12 +317,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.PAUSE_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.PAUSE_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -344,12 +343,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.RESUME_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.RESUME_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -367,12 +366,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.START_GATEWAYRECEIVER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.START_GATEWAYRECEIVER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -393,12 +392,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.START_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.START_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -415,12 +414,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.STATUS_GATEWAYRECEIVER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.STATUS_GATEWAYRECEIVER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -439,12 +438,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.STATUS_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.STATUS_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -461,12 +460,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.STOP_GATEWAYRECEIVER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.STOP_GATEWAYRECEIVER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
@@ -485,12 +484,12 @@ public class WanCommandsController extends AbstractCommandsController {
if (hasValue(groups)) {
command.addOption(CliStrings.STOP_GATEWAYSENDER__GROUP,
- StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
if (hasValue(members)) {
command.addOption(CliStrings.STOP_GATEWAYSENDER__MEMBER,
- StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+ StringUtils.join(members, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java
index cef8cab..3ec04c7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java
@@ -14,16 +14,16 @@
*/
package org.apache.geode.management.internal.web.domain;
-import java.io.Serializable;
-import java.net.URI;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
import org.apache.geode.internal.lang.ObjectUtils;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.management.internal.web.http.HttpMethod;
import org.apache.geode.management.internal.web.util.UriUtils;
+import java.io.Serializable;
+import java.net.URI;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
/**
* The Link class models hypermedia controls/link relations.
* <p/>
@@ -97,7 +97,7 @@ public class Link implements Comparable<Link>, Serializable {
}
public final void setRelation(final String relation) {
- assert !StringUtils.isBlank(relation) : "The Link relation (rel) must be specified!";
+ assert StringUtils.isNotBlank(relation) : "The Link relation (rel) must be specified!";
this.relation = relation;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/LinkIndex.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/LinkIndex.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/LinkIndex.java
index 7d5bb37..2a99e82 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/LinkIndex.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/LinkIndex.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.management.internal.web.domain;
+import org.apache.commons.lang.StringUtils;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -26,8 +28,6 @@ import java.util.TreeSet;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.geode.internal.lang.StringUtils;
-
/**
* The LinkIndex class is abstraction for modeling an index of Links.
* <p/>
@@ -127,7 +127,7 @@ public class LinkIndex implements Iterable<Link> {
int count = 0;
for (final Link link : this) {
- buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY_STRING).append(link);
+ buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY).append(link);
}
buffer.append("]");
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/HttpHeader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/HttpHeader.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/HttpHeader.java
index ee7e932..74836bc 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/HttpHeader.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/HttpHeader.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.management.internal.web.http;
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
/**
* The HttpHeader enum is an enumeration of all HTTP request/response header names.
@@ -78,7 +78,7 @@ public enum HttpHeader {
private final String name;
HttpHeader(final String name) {
- assert !StringUtils.isBlank(name) : "The name of the HTTP request header must be specified!";
+ assert StringUtils.isNotBlank(name) : "The name of the HTTP request header must be specified!";
this.name = name;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
index eeedf40..13fd42c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
@@ -15,9 +15,9 @@
package org.apache.geode.management.internal.web.shell;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.internal.lang.Filter;
import org.apache.geode.internal.lang.Initable;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.util.CollectionUtils;
import org.apache.geode.management.internal.cli.CommandRequest;
@@ -447,7 +447,7 @@ public class RestHttpOperationInvoker extends AbstractHttpOperationInvoker imple
@Override
public boolean accept(final Map.Entry<String, String> entry) {
- return !StringUtils.isBlank(entry.getValue());
+ return StringUtils.isNotBlank(entry.getValue());
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/ConvertUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/util/ConvertUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/ConvertUtils.java
index f3b092d..0b6fbe3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/util/ConvertUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/ConvertUtils.java
@@ -14,19 +14,18 @@
*/
package org.apache.geode.management.internal.web.util;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.geode.internal.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.web.io.MultipartFileResourceAdapter;
-
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* The ConvertUtils class is a support class for performing conversions used by the GemFire web
* application and REST interface.
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/UriUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/util/UriUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/UriUtils.java
index b83064e..a22ee13 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/util/UriUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/util/UriUtils.java
@@ -19,8 +19,6 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Map;
-import org.apache.geode.internal.lang.StringUtils;
-
/**
* The UriUtils is a utility class for processing URIs and URLs.
* <p/>
@@ -32,7 +30,7 @@ import org.apache.geode.internal.lang.StringUtils;
@SuppressWarnings("unused")
public abstract class UriUtils {
- public static final String DEFAULT_ENCODING = StringUtils.UTF_8;
+ public static final String DEFAULT_ENCODING = "UTF-8";
/**
* Decodes the encoded String value using the default encoding, UTF-8. It is assumed the String
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/cache/client/internal/LocatorTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/LocatorTestBase.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/LocatorTestBase.java
index c3b349a..7c168dc 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/LocatorTestBase.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/LocatorTestBase.java
@@ -14,10 +14,20 @@
*/
package org.apache.geode.cache.client.internal;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-
-import org.apache.geode.cache.*;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.Scope;
import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.server.CacheServer;
@@ -25,16 +35,26 @@ import org.apache.geode.cache.server.ServerLoadProbe;
import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.distributed.Locator;
import org.apache.geode.internal.cache.PoolFactoryImpl;
-import org.apache.geode.test.dunit.*;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.Invoke;
+import org.apache.geode.test.dunit.LogWriterUtils;
+import org.apache.geode.test.dunit.NetworkUtils;
+import org.apache.geode.test.dunit.SerializableCallable;
+import org.apache.geode.test.dunit.SerializableRunnable;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
-import java.util.*;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
/**
*
@@ -198,8 +218,8 @@ public abstract class LocatorTestBase extends JUnit4DistributedTestCase {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, locators);
- if (useGroupsProperty) {
- props.setProperty(GROUPS, StringUtils.concat(groups, ","));
+ if (useGroupsProperty && groups != null) {
+ props.setProperty(GROUPS, StringUtils.join(groups, ","));
}
DistributedSystem ds = getSystem(props);
Cache cache = CacheFactory.create(ds);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTestCase.java b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTestCase.java
index 09fa09e..bf6a854 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTestCase.java
@@ -17,9 +17,9 @@ package org.apache.geode.distributed;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.junit.Assert.assertTrue;
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.process.PidUnavailableException;
import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
index 62d4bdd..416b459 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
@@ -14,10 +14,14 @@
*/
package org.apache.geode.distributed;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import org.apache.geode.internal.lang.StringUtils;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -108,11 +112,11 @@ public class AbstractLauncherTest {
assertNotNull(distributedSystemProperties);
assertFalse(distributedSystemProperties.containsKey(NAME));
- launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "333");
+ launcher = createAbstractLauncher(StringUtils.EMPTY, "333");
assertNotNull(launcher);
assertEquals("333", launcher.getMemberId());
- assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+ assertEquals(StringUtils.EMPTY, launcher.getMemberName());
distributedSystemProperties = launcher.getDistributedSystemProperties();
@@ -166,11 +170,11 @@ public class AbstractLauncherTest {
assertNull(launcher.getMemberName());
assertEquals("123", launcher.getMember());
- launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "123");
+ launcher = createAbstractLauncher(StringUtils.EMPTY, "123");
assertNotNull(launcher);
assertEquals("123", launcher.getMemberId());
- assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+ assertEquals(StringUtils.EMPTY, launcher.getMemberName());
assertEquals("123", launcher.getMember());
launcher = createAbstractLauncher(" ", "123");
@@ -180,10 +184,10 @@ public class AbstractLauncherTest {
assertEquals(" ", launcher.getMemberName());
assertEquals("123", launcher.getMember());
- launcher = createAbstractLauncher(null, StringUtils.EMPTY_STRING);
+ launcher = createAbstractLauncher(null, StringUtils.EMPTY);
assertNotNull(launcher);
- assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberId());
+ assertEquals(StringUtils.EMPTY, launcher.getMemberId());
assertNull(launcher.getMemberName());
assertNull(launcher.getMember());
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
index 5b53c6a..b856361 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
@@ -14,6 +14,12 @@
*/
package org.apache.geode.distributed;
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.assertj.core.api.BDDAssertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.then;
+
import org.apache.geode.distributed.LocatorLauncher.Builder;
import org.apache.geode.distributed.LocatorLauncher.Command;
import org.apache.geode.distributed.internal.DistributionConfig;
@@ -33,12 +39,6 @@ import java.io.IOException;
import java.net.InetAddress;
import java.util.Properties;
-import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static org.assertj.core.api.BDDAssertions.assertThat;
-import static org.assertj.core.api.BDDAssertions.then;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
/**
* Integration tests for LocatorLauncher. These tests require file system I/O.
*/
@@ -110,7 +110,7 @@ public class LocatorLauncherIntegrationTest {
gemfireProperties);
// when: starting with null MemberName
- LocatorLauncher launcher = new Builder().setCommand(Command.START).setMemberName(null).build();
+ LocatorLauncher launcher = new Builder().setCommand(Command.START).build();
// then: name in gemfire.properties file should be used for MemberName
assertThat(launcher).isNotNull();
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
index 06d6054..50cea4d 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
@@ -14,13 +14,22 @@
*/
package org.apache.geode.distributed;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import org.apache.geode.distributed.LocatorLauncher.Builder;
import org.apache.geode.distributed.LocatorLauncher.Command;
import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.test.junit.categories.FlakyTest;
import org.apache.geode.test.junit.categories.UnitTest;
-import joptsimple.OptionException;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
@@ -29,9 +38,8 @@ import org.junit.rules.TestName;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import joptsimple.OptionException;
-import static org.junit.Assert.*;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
/**
* The LocatorLauncherTest class is a test suite of test cases for testing the contract and
@@ -53,6 +61,11 @@ public class LocatorLauncherTest {
@Rule
public final TestName testName = new TestName();
+ @Before
+ public void setup() {
+ DistributedSystem.removeSystem(InternalDistributedSystem.getConnectedInstance());
+ }
+
@Test(expected = IllegalArgumentException.class)
public void testBuilderParseArgumentsWithNonNumericPort() {
try {
@@ -154,8 +167,6 @@ public class LocatorLauncherTest {
assertNull(builder.getHostnameForClients());
assertSame(builder, builder.setHostnameForClients("Pegasus"));
assertEquals("Pegasus", builder.getHostnameForClients());
- assertSame(builder, builder.setHostnameForClients(null));
- assertNull(builder.getHostnameForClients());
}
@Test(expected = IllegalArgumentException.class)
@@ -184,6 +195,19 @@ public class LocatorLauncherTest {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testSetHostnameForClientsWithNullString() {
+ try {
+ new Builder().setHostnameForClients(null);
+ } catch (IllegalArgumentException expected) {
+ assertEquals(
+ LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
+ .toLocalizedString(),
+ expected.getMessage());
+ throw expected;
+ }
+ }
+
@Test
public void testSetAndGetMemberName() {
Builder builder = new Builder();
@@ -191,8 +215,6 @@ public class LocatorLauncherTest {
assertNull(builder.getMemberName());
assertSame(builder, builder.setMemberName("locatorOne"));
assertEquals("locatorOne", builder.getMemberName());
- assertSame(builder, builder.setMemberName(null));
- assertNull(builder.getMemberName());
}
@Test(expected = IllegalArgumentException.class)
@@ -219,6 +241,18 @@ public class LocatorLauncherTest {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testSetMemberNameWithNullString() {
+ try {
+ new Builder().setMemberName(null);
+ } catch (IllegalArgumentException expected) {
+ assertEquals(
+ LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Locator"),
+ expected.getMessage());
+ throw expected;
+ }
+ }
+
@Test
public void testSetAndGetPid() {
Builder builder = new Builder();
@@ -299,7 +333,7 @@ public class LocatorLauncherTest {
.setHostnameForClients("beanstock.vmware.com").setMemberName("Beanstock").setPort(8192)
.build();
- assertNotNull(launcher);
+ assertThat(launcher).isNotNull();
assertEquals(builder.getCommand(), launcher.getCommand());
assertTrue(launcher.isDebugging());
assertEquals(builder.getHostnameForClients(), launcher.getHostnameForClients());
@@ -312,10 +346,10 @@ public class LocatorLauncherTest {
@Test
public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
- LocatorLauncher launcher = new Builder().setCommand(LocatorLauncher.Command.START)
- .setMemberName(null).set(NAME, "locatorABC").build();
+ LocatorLauncher launcher =
+ new Builder().setCommand(LocatorLauncher.Command.START).set(NAME, "locatorABC").build();
- assertNotNull(launcher);
+ assertThat(launcher).isNotNull();
assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
assertNull(launcher.getMemberName());
assertEquals("locatorABC", launcher.getProperties().getProperty(NAME));
@@ -325,10 +359,9 @@ public class LocatorLauncherTest {
public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + NAME, "locatorXYZ");
- LocatorLauncher launcher =
- new Builder().setCommand(LocatorLauncher.Command.START).setMemberName(null).build();
+ LocatorLauncher launcher = new Builder().setCommand(LocatorLauncher.Command.START).build();
- assertNotNull(launcher);
+ assertThat(launcher).isNotNull();
assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
assertNull(launcher.getMemberName());
}