Skip to content

Commit

Permalink
[FLINK-19836] Add SerializableSupplier in flink-core
Browse files Browse the repository at this point in the history
This existed in tests before but I'm planning to use this in
SimpleVersionedSerializerTypeSerializerProxy and it fits with the other
special purpose Suppliers.
  • Loading branch information
aljoscha committed Oct 29, 2020
1 parent eb24d38 commit 91583c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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:https://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.util.function;

import org.apache.flink.annotation.Internal;

import java.io.Serializable;
import java.util.function.Supplier;

/**
* A serializable {@link Supplier}.
*
* @param <T> the type of results supplied by this supplier
*/
@Internal
@FunctionalInterface
public interface SerializableSupplier<T> extends Supplier<T>, Serializable {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple1;
import org.apache.flink.util.function.SerializableSupplier;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -30,7 +31,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.function.Supplier;

/**
* Tests for {@link ClosureCleaner}.
Expand Down Expand Up @@ -454,11 +454,6 @@ public MapFunction<Integer, Integer> getMap() {
}
}

@FunctionalInterface
interface SerializableSupplier<T> extends Supplier<T>, Serializable {

}

class NestedSelfReferencing implements Serializable {

private final SerializableSupplier<NestedSelfReferencing> cycle;
Expand Down

0 comments on commit 91583c7

Please sign in to comment.