/*
 * 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.commons.io.input;

import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;

import org.junit.jupiter.api.Test;

/**
 * Test {@link ProxyReader}.
 *
 */
public class ProxyReaderTest {

    @Test
    public void testNullCharArray() throws Exception {

        final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0));
        proxy.read((char[])null);
        proxy.read(null, 0, 0);
        proxy.close();
    }

    @Test
    public void testNullCharBuffer() throws Exception {

        final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0));
        proxy.read((CharBuffer)null);
        proxy.close();
    }

    /** ProxyReader implementation */
    private static class ProxyReaderImpl extends ProxyReader {
        ProxyReaderImpl(final Reader proxy) {
            super(proxy);
        }
    }

    /** Custom NullReader implementation */
    private static class CustomNullReader extends NullReader {
        CustomNullReader(final int len) {
            super(len);
        }
        @Override
        public int read(final char[] chars) throws IOException {
            return chars == null ? 0 : super.read(chars);
        }
        @Override
        public int read(final CharBuffer target) throws IOException {
            return target == null ? 0 : super.read(target);
        }
    }
}

@@ -983,19 +983,16 @@
 eader%7D.%0A
- *%0A
  */%0Apubl
@@ -1080,33 +1080,32 @@
 Exception %7B%0A
-%0A
         
 final ProxyR
@@ -1084,32 +1084,37 @@
 ption %7B%0A        
+try (
 final ProxyReade
@@ -1159,34 +1159,40 @@
 omNullReader(0))
-;%0A
+) %7B%0A    
         proxy.re
@@ -1202,16 +1202,17 @@
 (char%5B%5D)
+ 
 null);%0A 
@@ -1210,32 +1210,36 @@
  null);%0A        
+ 
+   
 proxy.read(null,
@@ -1250,38 +1250,25 @@
 0);%0A        
-proxy.close();
+%7D
 %0A    %7D%0A%0A    
@@ -1329,25 +1329,24 @@
 ption %7B%0A
-%0A
         
 final Pr
@@ -1337,16 +1337,21 @@
         
+try (
 final Pr
@@ -1412,18 +1412,24 @@
 ader(0))
-;%0A
+) %7B%0A    
         
@@ -1451,16 +1451,17 @@
 rBuffer)
+ 
 null);%0A 
@@ -1471,22 +1471,9 @@
     
-proxy.close();
+%7D
 %0A   
@@ -1841,32 +1841,33 @@
 len);%0A        %7D%0A
+%0A
         @Overrid
@@ -1997,24 +1997,25 @@
 ;%0A        %7D%0A
+%0A
         @Ove

Use try-with-resources. Javadoc.