[ 
https://issues.apache.org/jira/browse/FLINK-6162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15938556#comment-15938556
 ] 

ASF GitHub Bot commented on FLINK-6162:
---------------------------------------

Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3595#discussion_r107696959
  
    --- Diff: 
flink-core/src/test/java/org/apache/flink/core/memory/ByteArrayOutputStreamWithPosTest.java
 ---
    @@ -0,0 +1,31 @@
    +/*
    + * 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.flink.core.memory;
    +
    +import org.junit.Test;
    +
    +public class ByteArrayOutputStreamWithPosTest {
    +   @Test
    +   public void setPositionWhenBufferIsFull() throws Exception {
    +           ByteArrayOutputStreamWithPos stream = new 
ByteArrayOutputStreamWithPos(32);
    --- End diff --
    
    I think it is stronger to replace `32` on these lines with a descriptive 
local variable. After initialization could add an assertion that 
`getBuf().length` equals that value.


> Fix bug in ByteArrayOutputStreamWithPos#setPosition
> ---------------------------------------------------
>
>                 Key: FLINK-6162
>                 URL: https://issues.apache.org/jira/browse/FLINK-6162
>             Project: Flink
>          Issue Type: Bug
>          Components: Core
>            Reporter: Wenlong Lyu
>            Assignee: Wenlong Lyu
>
> Currently the precondition check in setPosition will fail when the buffer is 
> full: 
> {{Preconditions.checkArgument(position < getEndPosition(), "Position out of 
> bounds.");}}
> We should allow the expected position to be the end position



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to