You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2018/07/05 19:53:52 UTC
svn commit: r1835183 - in /poi/trunk/src:
java/org/apache/poi/ss/usermodel/Workbook.java
java/org/apache/poi/util/IOUtils.java
testcases/org/apache/poi/util/TestIOUtils.java
Author: centic
Date: Thu Jul 5 19:53:52 2018
New Revision: 1835183
URL: http://svn.apache.org/viewvc?rev=1835183&view=rev
Log:
Adjust comments and IDE warnings, duplicate code reduction
Modified:
poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java
poi/trunk/src/java/org/apache/poi/util/IOUtils.java
poi/trunk/src/testcases/org/apache/poi/util/TestIOUtils.java
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java?rev=1835183&r1=1835182&r2=1835183&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java Thu Jul 5 19:53:52 2018
@@ -369,10 +369,10 @@ public interface Workbook extends Closea
* @param nameIndex position of the named range (0-based)
* @return the defined name at the specified index
* @throws IllegalArgumentException if the supplied index is invalid
- * @deprecated 3.18. New projects should avoid accessing named ranges by index.
+ * @deprecated 4.0.0. New projects should avoid accessing named ranges by index.
*/
@Deprecated
- @Removal(version="3.20")
+ @Removal(version="5.0.0")
Name getNameAt(int nameIndex);
/**
Modified: poi/trunk/src/java/org/apache/poi/util/IOUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IOUtils.java?rev=1835183&r1=1835182&r2=1835183&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IOUtils.java Thu Jul 5 19:53:52 2018
@@ -140,13 +140,7 @@ public final class IOUtils {
if (length > (long)Integer.MAX_VALUE) {
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
}
- if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
- if (length > BYTE_ARRAY_MAX_OVERRIDE) {
- throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
- }
- } else if (length > maxLength) {
- throwRFE(length, maxLength);
- }
+ checkLength(length, maxLength);
final int len = Math.min((int)length, maxLength);
ByteArrayOutputStream baos = new ByteArrayOutputStream(len == Integer.MAX_VALUE ? 4096 : len);
@@ -172,7 +166,17 @@ public final class IOUtils {
return baos.toByteArray();
}
-
+ private static void checkLength(long length, int maxLength) {
+ if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
+ if (length > BYTE_ARRAY_MAX_OVERRIDE) {
+ throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
+ }
+ } else if (length > maxLength) {
+ throwRFE(length, maxLength);
+ }
+ }
+
+
/**
* Returns an array (that shouldn't be written to!) of the
* ByteBuffer. Will be of the requested length, or possibly
@@ -540,13 +544,7 @@ public final class IOUtils {
if (length > (long)Integer.MAX_VALUE) {
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
}
- if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
- if (length > BYTE_ARRAY_MAX_OVERRIDE) {
- throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
- }
- } else if (length > maxLength) {
- throwRFE(length, maxLength);
- }
+ checkLength(length, maxLength);
return new byte[(int)length];
}
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestIOUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestIOUtils.java?rev=1835183&r1=1835182&r2=1835183&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestIOUtils.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestIOUtils.java Thu Jul 5 19:53:52 2018
@@ -59,7 +59,7 @@ public final class TestIOUtils {
}
@AfterClass
- public static void tearDown() throws IOException {
+ public static void tearDown() {
assertTrue(TMP.delete());
}
@@ -99,13 +99,13 @@ public final class TestIOUtils {
}
@Test
- public void testToByteArrayByteBuffer() throws Exception {
+ public void testToByteArrayByteBuffer() {
assertArrayEquals(new byte[] { 1, 2, 3},
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3}), 10));
}
@Test
- public void testToByteArrayByteBufferToSmall() throws Exception {
+ public void testToByteArrayByteBufferToSmall() {
assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7},
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3, 4, 5, 6, 7}), 3));
}
@@ -210,19 +210,19 @@ public final class TestIOUtils {
int readCalled;
@Override
- public int read() throws IOException {
+ public int read() {
readCalled++;
return 0;
}
@Override
- public int read(byte[] arr, int offset, int len) throws IOException {
+ public int read(byte[] arr, int offset, int len) {
readCalled++;
return len;
}
@Override
- public long skip(long len) throws IOException {
+ public long skip(long len) {
skipCalled++;
if (skipCalled == 1) {
return 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org