flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-6162) Fix bug in ByteArrayOutputStreamWithPos#setPosition
Date Thu, 23 Mar 2017 15:22:41 GMT

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

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_r107697744
  
    --- 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);
    +		stream.write(new byte[32]);
    +		stream.setPosition(stream.getPosition());
    --- End diff --
    
    Assert that `getPosition` is equal to the expected value. Can validate that `setPosition`
now works per the change above and does not change the position, and also check that `toString`
can be executed.


> 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)

Mime
View raw message