Use stdlib IntFunction to not allow throwing (#2200)

This commit is contained in:
Matthew de Detrich 2025-09-15 13:19:27 +02:00 committed by GitHub
parent 94ae86fa6f
commit daf3458185
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 58 deletions

View file

@ -1,37 +0,0 @@
/*
* 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.pekko.japi.function;
/**
* Int function that can throw exceptions.
*
* @since 2.0.0
*/
@FunctionalInterface
public interface IntFunction<R> extends java.io.Serializable {
long serialVersionUID = 1L;
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws Throwable if an error occurs
*/
R apply(int value) throws Throwable;
}

View file

@ -1,19 +0,0 @@
/*
* 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.
*/
/** Java API for functional programming in Pekko. */
package org.apache.pekko.japi.function;

View file

@ -15,6 +15,7 @@ package org.apache.pekko.pattern
import java.util.Optional
import java.util.concurrent.{ Callable, CompletionStage, TimeUnit }
import java.util.function.IntFunction
import scala.concurrent.ExecutionContext
@ -812,7 +813,7 @@ object Patterns {
def retry[T](
attempt: Callable[CompletionStage[T]],
attempts: Int,
delayFunction: japi.function.IntFunction[Optional[java.time.Duration]],
delayFunction: IntFunction[Optional[java.time.Duration]],
scheduler: Scheduler,
context: ExecutionContext): CompletionStage[T] = {
import pekko.util.OptionConverters._
@ -853,7 +854,7 @@ object Patterns {
attempt: Callable[CompletionStage[T]],
shouldRetry: japi.function.Predicate2[T, Throwable],
attempts: Int,
delayFunction: japi.function.IntFunction[Optional[java.time.Duration]],
delayFunction: IntFunction[Optional[java.time.Duration]],
scheduler: Scheduler,
context: ExecutionContext): CompletionStage[T] = {
import pekko.util.OptionConverters._