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

Properties with commas in the value #2224

Closed
ionfist opened this issue Jan 9, 2020 · 8 comments · Fixed by #3522
Closed

Properties with commas in the value #2224

ionfist opened this issue Jan 9, 2020 · 8 comments · Fixed by #3522
Assignees
Milestone

Comments

@ionfist
Copy link

ionfist commented Jan 9, 2020

Environment:

  • Jib version: 1.7.0
  • Build tool: Maven
  • OS: Windows

Description of the issue:

Cannot specify a property with comma in the value. Looking at the code it looks very simple, it would be good if there was a way to be able to specify comma as a value by, somehow, escaping it.

Expected behavior:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005

The above will split the jvmFlags on each comma. It would be nice if one can escape the commas and pass the whole value as is.

Steps to reproduce:

  1. Specify -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
  2. After build the entry point jvm flags will be split into ['-agentlib:jdwp=transport=dt_socket', 'server=y', 'suspend=n', 'address=*:5005']
@ionfist ionfist changed the title Comma separated properties Properties with commas in the value Jan 9, 2020
@TadCordle
Copy link
Contributor

TadCordle commented Jan 9, 2020

You should be able to escape commas already with a \:

-agentlib:jdwp=transport=dt_socket\,server=y\,suspend=n\,address=*:5005

Feel free to reopen if that doesn't work for some reason.

@TadCordle
Copy link
Contributor

Hmm, actually, when you said "properties" I assumed you meant system properties. Is this about the JVM flags in the entrypoint itself? Maybe this actually could be a problem.

@TadCordle TadCordle reopened this Jan 9, 2020
@chanseokoh
Copy link
Member

I set

<container>
            <jvmFlags>
              <flag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</flag>
            </jvmFlags>
</container>

and the entrypoint I get from docker inspect is

            "Entrypoint": [                     
                "java",                         
                "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005",                                                                                                            
                "-cp",                          
                "/app/resources:/app/classes:/app/libs/*",                                       
                "example.HelloJarWorld"                                                          
            ],                                  

which is correct. So I think @ionfist was talking about system properties passed with -Djib.container.jvmFlags=.... And I thought \, would work, but looks like it doesn't work as expected :/

@loosebazooka
Copy link
Member

loosebazooka commented Jan 9, 2020

The problem is if you use

<jvmFlags>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</jvmFlags>

Since jvmFlags is a list, maven will automatically split it into a list unless you specify each list element separately as in @chanseokoh example above using <flag>

@ionfist
Copy link
Author

ionfist commented Jan 10, 2020

Hello,

<container>
            <jvmFlags>
              <flag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</flag>
            </jvmFlags>
</container>

This did the trick, thank you very much!
I totally missed that you can have multiple elements under jvmFlags. However, checking the documentation again it mentions using:

<jvmFlags>
    <jvmFlag></jvmFlag>
</jvmFlags>

Both seem to work, anyway thanks for the prompt help!

@chrisliebaer
Copy link

Not sure if that is related to command line properties but building an image using

-Djib.container.jvmFlags="-agentlib:jdwp=transport=dt_socket\,server=y\,suspend=y\,address=*:5005"

leads to the following entrypoint:

            "Entrypoint": [
                "java",
                "-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:5005",
                "-cp",
                "@/app/jib-classpath-file",

(note that the double backslashes are created by docker inspect)

While using

-Djib.container.jvmFlags="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"

splits them into individual arguments.

"Entrypoint": [
                "java",
                "-agentlib:jdwp=transport=dt_socket",
                "server=y",
                "suspend=y",
                "address=*:5005",
                "-cp",
                "@/app/jib-classpath-file",

Both of which will not work and make it impossible to actually specify jvmFlags (and probably any other list) via properties. Not sure why the backslash appears to change the splitting behaviour, I guess the backslash is not properly removed during input parsing?

@chanseokoh
Copy link
Member

Yeah, as I mentioned in #2224 (comment), I see this is still the problem when providing a list or map value on the command-line.

@chanseokoh
Copy link
Member

Will be fixed by #3522. Until that is merged and we release a new version, please use a workaround utilizing a Maven profile.

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

Successfully merging a pull request may close this issue.

6 participants