-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add additional JVM parameters [ECR-1769] #342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add some tests.
Also, have you explored _JAVA_OPTIONS
environment variable that Travis apparently uses? I've seen message from the JVM like picked up _JAVA_OPTIONS=…
. I wonder if it works in our case.
/// Additional parameters for JVM. | ||
/// | ||
/// Passed directly to JVM while initializing EJB runtime. | ||
/// Parameters must not have dash at the beginning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if a user passes one? Do we check it anywhere and show a descriptive error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably good catch! In case of invalid parameter JVM will return pretty descriptive error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's impossible to pass a parameter with a dash (Exonum core considers it as an unknown cmd flag)
@@ -58,8 +58,9 @@ impl JavaServiceRuntime { | |||
fn create_java_vm(config: JvmConfig) -> JavaVM { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
#[derive(Debug, Clone, Copy)] | ||
pub enum UserParameterError { | ||
/// Trying to specify a parameter that is set by EJB internally. | ||
ForbiddenParameter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that displayed to the user? Can we include a parameter that they shall use instead in the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I will improve this
Lol. As I thought, forbidding |
…service # Conflicts: # exonum-java-binding-qa-service/pom.xml
# Conflicts: # exonum-java-binding-core/rust/ejb-app/start_cryptocurrency_node.sh
/// TODO | ||
/// Panics if `_JAVA_OPTIONS` environmental variable is set. | ||
pub fn panic_if_java_options() { | ||
if env::var("_JAVA_OPTIONS").is_ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember you wrote me there are several of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, only _JAVA_OPTIONS
is important for us, cause only this variable can overwrite command-line args
Marking as wip until tests are added |
@dmitry-timofeev do we need any other tests? |
@@ -7,7 +7,7 @@ use exonum::node::NodeConfig; | |||
use failure; | |||
use toml::Value; | |||
|
|||
const EJB_DEBUG: &str = "EJB_DEBUG"; | |||
const EJB_USER_PARAMETERS: &str = "EJB_USER_PARAMETERS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JVM_ARGUMENTS?
(EJB_USER_PARAMETERS suggests that these are parameters of EJB).
false, | ||
"Debug mode for JVM.", | ||
"Additional parameters for JVM.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be shown in help? If so, I'd document that these parameters must not have a leading dash (-
), e.g., Xmx2G
.
} | ||
|
||
fn check_not_forbidden(user_parameter: &str) -> Result<(), ForbiddenParameterError> { | ||
if user_parameter.contains("Djava.class.path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't contains to restrictive (what if I want to specify a custom property, e.g., -Dfoo.bar=bazDjava.class.path
)? Maybe starts_with?
let validation_result = validate_and_convert("Xdebug"); | ||
assert_eq!(validation_result, Ok("-Xdebug".to_string())); | ||
|
||
let validation_result = validate_and_convert("Duser.parameter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into two tests to keep them focused?
pub fn panic_if_java_options() { | ||
if env::var("_JAVA_OPTIONS").is_ok() { | ||
panic!( | ||
"_JAVA_OPTIONS environmental variable is set. \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment
if env::var("_JAVA_OPTIONS").is_ok() { | ||
panic!( | ||
"_JAVA_OPTIONS environmental variable is set. \ | ||
Due to the fact that it will overwrite any JVM setting, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any JVM settings
Due to the fact that it will overwrite any JVM setting, \ | ||
including ones set by EJB internally, this variable is \ | ||
forbidden for EJB applications.\n\ | ||
It is recommend to use `--ejb-jvm-args` command-line \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended
Overview
Add additional user-specified JVM parameters, remove
debug
setting.See: https://jira.bf.local/browse/ECR-1769
Definition of Done