/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.reef.io.network.util;

import java.io.ByteArrayOutputStream;

import org.apache.commons.lang3.Validate;

/**
 * Avoids re-sizing of the backing array.
 */
public class ZeroCopyByteArrayOutputStream extends ByteArrayOutputStream {

	private final int size;

	public ZeroCopyByteArrayOutputStream(final int size) {
		super(size);
		this.size = size;
	}

	@Override
	public synchronized byte[] toByteArray() {
		Validate.isTrue(count == size, "count is %d but size is %d, they should be equal!", count, size);
		return buf;
	}

}

@@ -1051,17 +1051,18 @@
 ream %7B%0A%0A
-%09
+  
 private 
@@ -1078,17 +1078,18 @@
  size;%0A%0A
-%09
+  
 public Z
@@ -1135,18 +1135,20 @@
 size) %7B%0A
-%09%09
+    
 super(si
@@ -1152,18 +1152,20 @@
 (size);%0A
-%09%09
+    
 this.siz
@@ -1178,13 +1178,15 @@
 ze;%0A
-%09%7D%0A%0A%09
+  %7D%0A%0A  
 @Ove
@@ -1191,17 +1191,18 @@
 verride%0A
-%09
+  
 public s
@@ -1236,18 +1236,20 @@
 ray() %7B%0A
-%09%09
+    
 Validate
@@ -1342,10 +1342,12 @@
 e);%0A
-%09%09
+    
 retu
@@ -1358,9 +1358,10 @@
 uf;%0A
-%09
+  
 %7D%0A%0A%7D

check style violations