tag r1806507 as 3.17

git-svn-id: https://svn.apache.org/repos/asf/poi/tags/REL_3_17_FINAL@1806508 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index 72be9b4..d6ff129 100644
--- a/build.xml
+++ b/build.xml
@@ -2408,7 +2408,8 @@
 
             <copy todir="${repo}">
                 <mappedresources>
-                    <fileset dir="build/dist/maven" includes="@{artifactId}/**"/>
+                	<!-- add sha-512 when nexus rules are updated (1/2) -->
+                    <fileset dir="build/dist/maven" includes="@{artifactId}/**" excludes="**/*.sha512"/>
                     <regexpmapper from="^([^/]+)/(.*)$$" to="org/apache/poi/\1/${version.id}/\2" handledirsep="true"/>
                 </mappedresources>
             </copy>
@@ -2434,10 +2435,11 @@
     <lastUpdated>${lastUpdated}</lastUpdated>
   </versioning>
 </metadata>]]></echo>
-            <fixcrlf srcdir="${metadir}" includes="maven-metadata.xml" eol="unix" eof="remove" />
-            <checksum algorithm="SHA-512" fileext=".sha512" format="MD5SUM">
+            <fixcrlf srcdir="${metadir}" includes="maven-metadata.xml" eol="unix" eof="remove" />                	<!-- add sha-512 when nexus rules are updated -->
+            <!-- add sha-512 when nexus rules are updated (2/2) -->
+            <!--checksum algorithm="SHA-512" fileext=".sha512" format="MD5SUM">
                 <fileset dir="${metadir}" includes="maven-metadata.xml"/>
-            </checksum>
+            </checksum-->
             <checksum algorithm="sha1" format="MD5SUM">
                 <fileset dir="${metadir}" includes="maven-metadata.xml"/>
             </checksum>
diff --git a/sonar/examples/pom.xml b/sonar/examples/pom.xml
index 914b2c6..955a117 100644
--- a/sonar/examples/pom.xml
+++ b/sonar/examples/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
     </parent>
     <artifactId>poi-examples</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/excelant/pom.xml b/sonar/excelant/pom.xml
index 90856ac..da39b40 100644
--- a/sonar/excelant/pom.xml
+++ b/sonar/excelant/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
     </parent>
     <artifactId>poi-excelant</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/main/pom.xml b/sonar/main/pom.xml
index 7ee617b..d0cee44 100644
--- a/sonar/main/pom.xml
+++ b/sonar/main/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
     </parent>
     <artifactId>poi-main</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/ooxml-schema-encryption/pom.xml b/sonar/ooxml-schema-encryption/pom.xml
index 111a782..f884902 100644
--- a/sonar/ooxml-schema-encryption/pom.xml
+++ b/sonar/ooxml-schema-encryption/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-encryption</artifactId>
diff --git a/sonar/ooxml-schema-security/pom.xml b/sonar/ooxml-schema-security/pom.xml
index 49ada48..ac7e4fa 100644
--- a/sonar/ooxml-schema-security/pom.xml
+++ b/sonar/ooxml-schema-security/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-security</artifactId>
diff --git a/sonar/ooxml-schema/pom.xml b/sonar/ooxml-schema/pom.xml
index 25b1b4b..24221f8 100644
--- a/sonar/ooxml-schema/pom.xml
+++ b/sonar/ooxml-schema/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema</artifactId>
diff --git a/sonar/ooxml/pom.xml b/sonar/ooxml/pom.xml
index 31f035e..bcbe995 100644
--- a/sonar/ooxml/pom.xml
+++ b/sonar/ooxml/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
     </parent>
     <artifactId>poi-ooxml</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/pom.xml b/sonar/pom.xml
index 3e9314c..0e141f7 100644
--- a/sonar/pom.xml
+++ b/sonar/pom.xml
@@ -3,7 +3,7 @@
 	<groupId>org.apache.poi</groupId>
 	<artifactId>poi-parent</artifactId>
 	<packaging>pom</packaging>
-	<version>3.17-beta2-SNAPSHOT</version>
+	<version>3.18-beta1-SNAPSHOT</version>
 	<name>Apache POI - the Java API for Microsoft Documents</name>
 	<description>Maven build of Apache POI for Sonar checks</description>
 	<url>http://poi.apache.org/</url>
diff --git a/sonar/scratchpad/pom.xml b/sonar/scratchpad/pom.xml
index f1b8485..12bc995 100644
--- a/sonar/scratchpad/pom.xml
+++ b/sonar/scratchpad/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>3.17-beta2-SNAPSHOT</version>
+        <version>3.18-beta1-SNAPSHOT</version>
     </parent>
     <artifactId>poi-scratchpad</artifactId>
     <packaging>jar</packaging>
diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java
index b256591..c2be578 100644
--- a/src/java/org/apache/poi/util/IOUtils.java
+++ b/src/java/org/apache/poi/util/IOUtils.java
@@ -206,7 +206,7 @@
      *
      * @param doc  a writeable document to write to the output stream
      * @param out  the output stream that the document is written to
-     * @throws IOException 
+     * @throws IOException thrown on errors writing to the stream
      */
     public static void write(POIDocument doc, OutputStream out) throws IOException {
         try {
@@ -225,7 +225,7 @@
      *
      * @param doc  a writeable document to write to the output stream
      * @param out  the output stream that the document is written to
-     * @throws IOException 
+     * @throws IOException thrown on errors writing to the stream
      */
     public static void write(Workbook doc, OutputStream out) throws IOException {
         try {
@@ -245,7 +245,7 @@
      *
      * @param doc  a writeable and closeable document to write to the output stream, then close
      * @param out  the output stream that the document is written to
-     * @throws IOException 
+     * @throws IOException thrown on errors writing to the stream
      */
     public static void writeAndClose(POIDocument doc, OutputStream out) throws IOException {
         try {
@@ -264,7 +264,7 @@
      *
      * @param doc  a writeable and closeable document to write to the output file, then close
      * @param out  the output file that the document is written to
-     * @throws IOException 
+     * @throws IOException thrown on errors writing to the stream
      */
     public static void writeAndClose(POIDocument doc, File out) throws IOException {
         try {
@@ -282,7 +282,7 @@
      * This function exists for Java 6 code.
      *
      * @param doc  a writeable document to write in-place
-     * @throws IOException 
+     * @throws IOException thrown on errors writing to the file
      */
     public static void writeAndClose(POIDocument doc) throws IOException {
         try {
diff --git a/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java b/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
index b518909..911eef6 100644
--- a/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
+++ b/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
@@ -71,7 +71,9 @@
         // DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096);
         
         // POI is not thread-safe - so we can switch to unsynchronized xmlbeans mode - see #61350
-        DEFAULT_XML_OPTIONS.setUnsynchronized();
+        // Update: disabled again for now as it caused strange NPEs and other problems
+        // when reading properties in separate workbooks in multiple threads
+        // DEFAULT_XML_OPTIONS.setUnsynchronized();
 
         Map<String, String> map = new HashMap<String, String>();
         map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
diff --git a/src/testcases/org/apache/poi/util/TestIOUtils.java b/src/testcases/org/apache/poi/util/TestIOUtils.java
index 825e35a..4a08a32 100644
--- a/src/testcases/org/apache/poi/util/TestIOUtils.java
+++ b/src/testcases/org/apache/poi/util/TestIOUtils.java
@@ -17,6 +17,7 @@
 
 package org.apache.poi.util;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
 import java.io.ByteArrayInputStream;
@@ -27,8 +28,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.PushbackInputStream;
+import java.nio.ByteBuffer;
 import java.util.Random;
 
+import org.apache.poi.EmptyFileException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -55,10 +59,58 @@
 
     @AfterClass
     public static void tearDown() throws IOException {
+        //noinspection ResultOfMethodCallIgnored
         TMP.delete();
     }
 
     @Test
+    public void testPeekFirst8Bytes() throws Exception {
+        assertArrayEquals("01234567".getBytes("UTF-8"),
+                IOUtils.peekFirst8Bytes(new ByteArrayInputStream("0123456789".getBytes("UTF-8"))));
+    }
+
+    @Test
+    public void testPeekFirst8BytesWithPushbackInputStream() throws Exception {
+        assertArrayEquals("01234567".getBytes("UTF-8"),
+                IOUtils.peekFirst8Bytes(new PushbackInputStream(new ByteArrayInputStream("0123456789".getBytes("UTF-8")), 8)));
+    }
+
+    @Test
+    public void testPeekFirst8BytesTooLessAvailable() throws Exception {
+        assertArrayEquals(new byte[] { 1, 2, 3, 0, 0, 0, 0, 0},
+                IOUtils.peekFirst8Bytes(new ByteArrayInputStream(new byte[] { 1, 2, 3})));
+    }
+
+    @Test(expected = EmptyFileException.class)
+    public void testPeekFirst8BytesEmpty() throws Exception {
+        IOUtils.peekFirst8Bytes(new ByteArrayInputStream(new byte[] {}));
+    }
+
+    @Test
+    public void testToByteArray() throws Exception {
+        assertArrayEquals(new byte[] { 1, 2, 3},
+                IOUtils.toByteArray(new ByteArrayInputStream(new byte[] { 1, 2, 3})));
+    }
+
+    @Test(expected = IOException.class)
+    public void testToByteArrayToSmall() throws Exception {
+        assertArrayEquals(new byte[] { 1, 2, 3},
+                IOUtils.toByteArray(new ByteArrayInputStream(new byte[] { 1, 2, 3}), 10));
+    }
+
+    @Test
+    public void testToByteArrayByteBuffer() throws Exception {
+        assertArrayEquals(new byte[] { 1, 2, 3},
+                IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3}), 10));
+    }
+
+    @Test
+    public void testToByteArrayByteBufferToSmall() throws Exception {
+        assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7},
+                IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3, 4, 5, 6, 7}), 3));
+    }
+
+    @Test
     public void testSkipFully() throws IOException {
         InputStream is =  new FileInputStream(TMP);
         long skipped = IOUtils.skipFully(is, 20000L);
@@ -91,6 +143,11 @@
     }
 
     @Test
+    public void testSkipFullyBug61294() throws IOException {
+        IOUtils.skipFully(new ByteArrayInputStream(new byte[0]), 1);
+    }
+
+    @Test
     public void testZeroByte() throws IOException {
         long skipped = IOUtils.skipFully((new ByteArrayInputStream(new byte[0])), 100);
         assertEquals("zero byte", -1L, skipped);
@@ -105,7 +162,7 @@
     @Test(expected = IllegalArgumentException.class)
     public void testSkipNegative() throws IOException {
         InputStream is =  new FileInputStream(TMP);
-        long skipped = IOUtils.skipFully(is, -1);
+        IOUtils.skipFully(is, -1);
     }
 
     @Test