Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling methods which use cluster under the hood can cause NullPointerExecption #1491

Closed
yuvalshi0 opened this issue Apr 9, 2022 · 0 comments · Fixed by #1492
Closed

Calling methods which use cluster under the hood can cause NullPointerExecption #1491

yuvalshi0 opened this issue Apr 9, 2022 · 0 comments · Fixed by #1492
Milestone

Comments

@yuvalshi0
Copy link
Contributor

yuvalshi0 commented Apr 9, 2022

Versions used

Akka version: latest (code on master)

Description

Consider the following code:

abstract class SpecBase(kafkaPort: Int) extends ScalatestKafkaSpec(kafkaPort) {
  protected def this() = this(kafkaPort = -1)
}

class FooTest extends SpecBase with TestcontainersKafkaLike {
  val bar = brokerContainers.head.getBrokerNum

}

Running this suite will result in the following exception:

An exception or error caused a run to abort: Cannot invoke "akka.kafka.testkit.internal.KafkaContainerCluster.getBrokers()" because the return value of "akka.kafka.testkit.internal.TestcontainersKafka$Spec.akka$kafka$testkit$internal$TestcontainersKafka$Spec$$cluster()" is null 
...

Of course, the issue here is that I'm trying to get information regarding the cluster when before I even started it.

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.
A proper exception, saying the cluster hasn't been started, will be thrown.

Actual Behavior

The method returns a NullPointerExecption

Suggested Solution

Check by default if the cluster has been started, like other methods do:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants