question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow call() with a parameterless "consumer" (e.g.. Runnable)

See original GitHub issue

There 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ePaulcommented, May 13, 2016

@tkrop I’m not sure I understand your question.

The point of call(...) is to specify code to execute, with capture() you say “store something for later retrieval”. (Though I’m not sure what is actually captured in your example.)

Currently I can say

rest.execute(GET, url).dispatch(status(),
          on(OK).call(response -> callback.successfullyPublished()));

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

rest.execute(GET, url).dispatch(status(),
          on(OK).call(callback::successfullyPublished));

directly. This is the difference between a Consumer<ClientHttpResponse> and a Runnable.

0reactions
ePaulcommented, May 13, 2016

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

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found