Skip to content
Permalink
Browse files
Reuse constant.
  • Loading branch information
garydgregory committed Jan 16, 2021
1 parent dfcecee commit ee9bbcd34619c529440fc9f2bb218ca75c62ed95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
@@ -46,6 +46,7 @@
import org.apache.commons.configuration2.sync.LockMode;
import org.apache.commons.configuration2.sync.NoOpSynchronizer;
import org.apache.commons.configuration2.sync.Synchronizer;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ObjectUtils;

@@ -1412,7 +1413,7 @@ public String getEncodedString(final String key)
public String[] getStringArray(final String key)
{
final String[] result = (String[]) getArray(String.class, key);
return result == null ? new String[0] : result;
return result == null ? ArrayUtils.EMPTY_STRING_ARRAY : result;
}

/**
@@ -41,6 +41,7 @@
import org.apache.commons.configuration2.event.EventType;
import org.apache.commons.configuration2.interpol.ConfigurationInterpolator;
import org.apache.commons.configuration2.interpol.Lookup;
import org.apache.commons.lang3.ArrayUtils;
import org.easymock.EasyMock;
import org.junit.Test;

@@ -814,7 +815,7 @@ public void testGetArrayPrimitive()
expected[i] = (short) i;
}
final short[] result =
config.get(short[].class, KEY_PREFIX, new short[0]);
config.get(short[].class, KEY_PREFIX, ArrayUtils.EMPTY_SHORT_ARRAY);
assertArrayEquals("Wrong result", expected, result);
}

@@ -44,6 +44,7 @@
import org.apache.commons.configuration2.io.FileHandler;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.commons.configuration2.tree.NodeHandler;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -214,7 +215,7 @@ public void testNestedDictionaries()
@Test
public void testData()
{
ObjectAssert.assertInstanceOf("data", new byte[0].getClass(), config.getProperty("data"));
ObjectAssert.assertInstanceOf("data", ArrayUtils.EMPTY_BYTE_ARRAY.getClass(), config.getProperty("data"));
ArrayAssert.assertEquals("data", "foo bar".getBytes(), (byte[]) config.getProperty("data"));
}

0 comments on commit ee9bbcd

Please sign in to comment.