You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2025/09/13 07:16:50 UTC

[PR] chore: Add boolean supplier that can throws. [pekko]

He-Pin opened a new pull request, #2199:
URL: https://github.com/apache/pekko/pull/2199

   Motivation:
   Better Java dsl support.
   
   on top of https://github.com/apache/pekko/pull/2198
   
   refs: https://github.com/apache/pekko/issues/2197


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2199:
URL: https://github.com/apache/pekko/pull/2199#discussion_r2345984914


##########
actor/src/main/java/org/apache/pekko/japi/pf/FSMStateFunctionBuilder.java:
##########
@@ -54,7 +54,7 @@ private FSMStateFunctionBuilder<S, D> erasedEvent(
         FSM.Event.class,
         new Predicate<FSM.Event>() {
           @Override
-          public boolean test(FSM.Event e) {
+          public boolean test(FSM.Event e) throws Exception {

Review Comment:
   I will rewrite these kinds to lambda once https://github.com/apache/pekko/pull/1986 gets merged



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287861364

   Let's push out 2.0.0-M1 to remove any time pressure so that we can get a few people to give their ideas in #2197. 
   I think everyone has valid points on this and I'm sure that we can find a consensus.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287778476

   > I think you need to refresh your knowledge about lambda, please check some other project first, eg: https://github.com/smallrye/smallrye-mutiny
   
   Linking me to some other projects without an explanation isn't very helpful. There is a reason why the pekko API originally created their own versions of functional interfaces like `Creator`, its because `Creator` could throw exceptions and in some cases supplying functions that throw exceptions makes sense (again resource acquisition).
   
   But if you have functions that are basic predicates, throwing functions especially in the context of pekko-streams can produce weird results. It also doesn't make any sense in terms of API design, what does an exception mean when thrown during a predicate? Should it be false? Should it be true? Should we cancel altogether? If the user is dealing with exceptions they should explicitly catch and map the exception to a `true`/`false`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287869353

   Other reactive libraries are also acceptable. This makes it easier for Java developers to interpret and call methods that throw exceptions, allowing them to be called normally in lambda. This is a very common problem that does not exist in Kotlin and Scala.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287773847

   @mdedetrich  There are some Java api should be changed. In the persistence plugin, I will leave that to you.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed pull request #2199: chore: Add boolean supplier that can throws.
URL: https://github.com/apache/pekko/pull/2199


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287809612

   > I don't want to explain any more. You understand RPC, right? You understand rate limiting, right? Can I use distributed rate limiting? Distributed rate limiting can use a Predicate abstraction, but will the distributed rate limiter throw an exception? I've decided to move on to other things and don't want to be blocked by you. This exception won't show up in a lambda scenario. You've been writing in Kotlin so much that you've forgotten how to write in Java.
   
   Again, this is the reason
   
   > what does an exception mean when thrown during a predicate? Should it be false? Should it be true? Should we cancel altogether? If the user is dealing with exceptions they should explicitly catch and map the exception to a `true`/`false`.
   
   Also this is how akka/pekko have historically worked, only functions used in resource acquisitions (like `mapWithResource`) are the ones that were allowed to throw exceptions


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287802092

   I don't want to explain any more. You understand RPC, right? You understand rate limiting, right? Can I use distributed rate limiting? Distributed rate limiting can use a Predicate abstraction, but will the distributed rate limiter throw an exception? I've decided to move on to other things and don't want to be blocked by you. This exception won't show up in a lambda scenario. You've been writing in Kotlin so much that you've forgotten how to write in Java.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287767244

   > By the way, you can never limit a user; do not throw an exception, as a user can always do something like sneakyThrow, with this, we can use some function which can throw inside a lambda
   
   No we should definitely limit what users can do, its part of good API design. Throwing exceptions in predicates make zero sense and leads to undefined behaviour in a lot of cases


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287758392

   @mdedetrich Fine,take the https://github.com/apache/pekko/issues/2197 from here.
   
   1. The current implementation does not match the Scala doc of both `Predicate` and `Predicate2ยท
   2. The Java BooleanSupplier can not throw, but you can actually inside a Scala's PartialFunction.
   
   <img width="1801" height="618" alt="image" src="https://github.com/user-attachments/assets/030b8912-dcac-404f-a0c1-6676898f932d" />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287762887

   By the way, you can never limit a user; do not throw an exception, as a user can always do something like sneakyThrow, with this, we can use some function which can throw inside a lambda
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Add boolean supplier that can throws. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2199:
URL: https://github.com/apache/pekko/pull/2199#issuecomment-3287770084

   I think you need to refresh your knowledge about lambda, please check some other project first, eg: https://github.com/smallrye/smallrye-mutiny


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org