Allow call() with a parameterless "consumer" (e.g.. Runnable)
See original GitHub issueThere are some cases where the conditions of the dispatch function are already everything which is interesting (i.e. neither response body nor any remaining header information matter). (An example is the 200
response from Nakadi’s “submit events” operation.)
But currently I still need to pass to .call()
a consumer of either some class mapped from the response, or even the HttpClientResponse.
I propose to add a call
method in UntypedCondition which accepts a Runnable
(or a throwing version thereof), simply discarding the ClientHttpResponse and calling the runnable.
For now I’m using this wrap
function as a workaround:
private static ThrowingConsumer<ClientHttpResponse, ?> wrap(Runnable runnable) {
return response -> runnable.run();
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Java 8 lambda Void argument - Stack Overflow
Use Consumer if it takes something, but returns nothing. Use Callable if it returns a result and might throw (most akin to Thunk...
Read more >java - What is the name of a function that takes no argument ...
Executor already exists and has another purpose : "An object that executes submitted Runnable tasks". The signature doesn't match ( execute( ...
Read more >How to use Java's functional Consumer interface example
Consumer class has one non-default method named accept which takes a single object as its argument and has a void return type. java.util....
Read more >Implement a Dispose method - Microsoft Learn
In this article, learn to implement the Dispose method, which releases unmanaged resources used by your code in .NET.
Read more >Implementing a Kafka consumer in Java - Mateusz Bukowicz
Introduction. In this post we will take a look at different ways how messages can be read from Kafka. Our goal will be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tkrop I’m not sure I understand your question.
The point of
call(...)
is to specify code to execute, withcapture()
you say “store something for later retrieval”. (Though I’m not sure what is actually captured in your example.)Currently I can say
But this response is not actually used in the callback (it’s a void method without parameters), thus I would like to be able to say
directly. This is the difference between a
Consumer<ClientHttpResponse>
and aRunnable
.First thing going wrong is that my home computer has no Java 8, and the Ubuntu is old enough there isn’t even a package to install it. So, it might take a while until I set up everything. (Also, 4 GB seems to not be enough to run Eclipse and Opera with several tabs open at the same time.)