Bug 574839: [R-Help] Enable DeflaterOutputStream.syncFlush

Change-Id: I2b50cf827cb3054a7212d8c5ff0c43a4332c5021
diff --git a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
index 24af5cb..b10df27 100644
--- a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
+++ b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
@@ -119,16 +119,20 @@
 		
 		public void enableCompression() {
 			DataStream.this.flags |= COMPRESS;
-			this.out= new DeflaterOutputStream(this.out, this.deflater, 4096);
+			this.out= new DeflaterOutputStream(this.out, this.deflater, 4096, true);
 		}
 		
 		@Override
 		public void close() throws IOException {
 			if (this.out != null) {
-				super.close();
-				this.out= null;
-				if ((DataStream.this.flags & COMPRESS) != 0) {
-					this.deflater.reset();
+				try {
+					super.close();
+				}
+				finally {
+					this.out= null;
+					if ((DataStream.this.flags & COMPRESS) != 0) {
+						this.deflater.reset();
+					}
 				}
 			}
 		}
@@ -159,10 +163,14 @@
 		@Override
 		public void close() throws IOException {
 			if (this.in != null) {
-				super.close();
-				this.in= null;
-				if ((DataStream.this.flags & COMPRESS) != 0) {
-					this.inflater.reset();
+				try {
+					super.close();
+				}
+				finally {
+					this.in= null;
+					if ((DataStream.this.flags & COMPRESS) != 0) {
+						this.inflater.reset();
+					}
 				}
 			}
 		}
diff --git a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
index 0adee45..2c9c68a 100644
--- a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
+++ b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
@@ -530,7 +530,7 @@
 		final ImList<String> topics;
 		{	final int nTopics= in.readInt();
 			final String[] array= new @NonNull String[nTopics];
-			for (int i= 0; i < array.length; i++) {
+			for (int i= 0; i < nTopics; i++) {
 				final String topic= in.readString();
 				array[i]= (topic == null) ? name : topic.intern();
 			}