On 1 March 2014 02:09, Gary Gregory <[email protected]> wrote: > On Fri, Feb 28, 2014 at 2:29 PM, <[email protected]> wrote: > >> Author: sebb >> Date: Fri Feb 28 19:29:12 2014 >> New Revision: 1573038 >> >> URL: http://svn.apache.org/r1573038 >> Log: >> Arrays#copyOfRange is Java 1.6+; replace with basic local implementation >> >> Ugh. Why not up to 1.6? 21st century and all.
Same response as always. Not everyone can update their Java version easily (or at all), so why exclude some end users unnecessarily when there is a trivial solution that benefits all end-users? Yes, there will come a time when it is necessary to drop 1.5 support, but that needs to be done on the basis of a code requirement. > Gary > > > >> >> Modified: >> >> commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java >> >> Modified: >> commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java?rev=1573038&r1=1573037&r2=1573038&view=diff >> >> ============================================================================== >> --- >> commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java >> (original) >> +++ >> commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java >> Fri Feb 28 19:29:12 2014 >> @@ -57,7 +57,7 @@ public class PythonTruncatedBzip2Test { >> DATA = out.toByteArray(); >> >> // Drop the eos_magic field (6 bytes) and CRC (4 bytes). >> - TRUNCATED_DATA = Arrays.copyOfRange(DATA, 0, DATA.length - 10); >> + TRUNCATED_DATA = copyOfRange(DATA, 0, DATA.length - 10); >> } >> >> @Before >> @@ -91,7 +91,7 @@ public class PythonTruncatedBzip2Test { >> ByteBuffer buffer = ByteBuffer.allocate(length); >> bz2Channel.read(buffer); >> >> - assertArrayEquals(Arrays.copyOfRange(TEXT.getBytes(), 0, length), >> + assertArrayEquals(copyOfRange(TEXT.getBytes(), 0, length), >> buffer.array()); >> >> // subsequent read should throw >> @@ -110,4 +110,13 @@ public class PythonTruncatedBzip2Test { >> >> return Channels.newChannel(bZin); >> } >> + >> + // Helper method since Arrays#copyOfRange is Java 1.6+ >> + // Does not check parameters, so may fail if they are incompatible >> + private static byte[] copyOfRange(byte[] original, int from, int to) { >> + int length = to - from; >> + byte buff[] = new byte[length]; >> + System.arraycopy(original, from, buff, 0, length); >> + return buff; >> + } >> } >> >> >> > > > -- > E-Mail: [email protected] | [email protected] > Java Persistence with Hibernate, Second > Edition<http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
