Fix case-sensitivity bug for port numbers in command#524
Conversation
This bug shows itself when a port number contains letters in the hexadecimal conversion.
| private void tryPort(Integer internalPort) { | ||
| String[][] commands = { | ||
| {"/bin/sh", "-c", format("cat /proc/net/tcp | awk '{print $2}' | grep :%x && echo %s", internalPort, SUCCESS_MARKER)}, | ||
| {"/bin/sh", "-c", format("cat /proc/net/tcp | awk '{print $2}' | grep :%X && echo %s", internalPort, SUCCESS_MARKER)}, |
There was a problem hiding this comment.
%x produces lower-case hexadecimal numbers, /proc/net/tcp has uppercase references. This only shows itself with ports that actually contain letters, of course. Hence the configuration change for the nginx instance to run on 8080, which is '1F90' in hex (as opposed to '1f90')...
There was a problem hiding this comment.
whoa! Nice one, thanks @dnno. We should probably change grep to -i to completely ignore the case in case of the case differences. WDYT?
There was a problem hiding this comment.
Right, that sounds reasonable. Will change that!
| @@ -3,31 +3,36 @@ | |||
| import com.google.common.collect.ImmutableSet; | |||
There was a problem hiding this comment.
could you please fix the indentation in this file?
Also, IMO we can just use nc for this test to avoid creating a config for nginx
There was a problem hiding this comment.
oh yes, sorry, will fix the indentation.
I had a problem with netcat and the infinispan container before, it's not installed. I could imagine other containers not supporting it, too. In fact I thought this was the reason for the /proc/net/tcp solution here.
| @@ -0,0 +1,44 @@ | |||
| server { | |||
There was a problem hiding this comment.
- please rename the file to something explicit, like
nginx_on_8080.conf, to avoid the confusion if this config is reused in some other test server { listen 8080; }should be enough for that test and will better indicate the purpose of this config
|
@dnno please also mention your change in |
|
Perfect! Thanks @dnno! |
|
My pleasure! 😊 |
* Fix case-sensitivity bug for port numbers in command This bug shows itself when a port number contains letters in the hexadecimal conversion. * Make grep ignore casing * Rename and cleanup Nginx test configuration file * Update the changelog for PR #524 * Fix a typo in the changelog
This bug shows itself when a port number contains letters in the hexadecimal conversion.