cannot find symbol symbol: variable param location: class com.twitter.finagle.transport.Transport.Liveness

178 views Asked by At

I'm using finagle scala library in my java code base.

Below is the sample code from finagle written in scala code.

    import com.twitter.finagle.transport.Transport
    import com.twitter.finagle.{Http, Stack}
    val client = Http.client
    val params: Stack.Params = client.params
    client.configured(client.params[Transport.Liveness].copy(keepAlive = Some(true)))

I wrote the same in java as below -

    import com.twitter.finagle.Http;
    import com.twitter.finagle.transport.Transport;

    public class FinagleClientDemo {
        public static void main(String[] args) {
            Http.Client  client = Http.client()
                    .withLabel("myLabel");
                client.withDecompression(true);
            Transport.Liveness liveness = client.params().apply(Transport.Liveness.param());
        }
    }

When I compile the program I get below error -

    [error] /Users/myuser/Documents/chapter14/src/main/java/FinagleClientDemo.java:9:1: cannot find symbol
    [error]   symbol:   method param()
    [error]   location: class com.twitter.finagle.transport.Transport.Liveness
    [error]         Transport.Liveness liveness = (Transport.Liveness)Http.client().params().apply(Transport.Liveness.param());
    [error] (Compile / compileIncremental) javac returned non-zero exit code
    [error] Total time: 4 s, completed Nov 6, 2018 1:10:43 PM
    2. Waiting for source changes in project chapter14... (press enter to interrupt)

What is the mistake I did here. How can I make my program compile?

1

There are 1 answers

0
user51 On BEST ANSWER

The answer is

Transport.Liveness liveness = client.params().apply(Transport.Liveness$.MODULE$.param());