harry potter
harry potter

Reputation: 350

How to enable assertions in AWS Lambda Java code?

How to enable assertions in AWS Lambda Java code ?

Basically I want AWS Lambda to take into account my assert statements in Java code.

Upvotes: 0

Views: 354

Answers (2)

Traycho Ivanov
Traycho Ivanov

Reputation: 3217

As mentioned by Bjorn you have too enable -enableassertions.

It is possible to have them but with using custom runtime not the default AWS. Here is one example of having custom runtime - https://github.com/andthearchitect/aws-lambda-java-runtime

Note: There is an option JAVA_TOOL_OPTIONS, please give it a try before checking custom runtime.

Another option could be just replace asserting with something like .

if (!condition) {
    throw new AssertionError();
}

If it is your own code second options sounds better.

Upvotes: 2

raupach
raupach

Reputation: 3102

To enable assertions assertions you need to use the -enableassertions startup command. Unfortunately you cannot give arguments to the JVM with AWS Lambda. Only environment variables are supported. To answer your question: no this is not possible.

Upvotes: 1

Related Questions