moved your impl in getNextAvailablePortInDefaultRange(), kept
getNextAvailablePort() using a really random port (what we want by
default locally at least + in arquillian where you can specified
ranges if relevant but not our default).

Increased min port to 1025 (tested only on unix machines but seems it
depends the default security of the distribution if 1024 is usable or
not)

Hope this is fine for you Andy.

Side note (more general): this class starts to get a real state and
seems to desire a lifecycle (when you don't use a port anymore you
should release it). I think we should extract it in "instances"
instead of having eveything static. We could then back our current API
by a single instance of the new impl.






Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-12-01 23:48 GMT+01:00 Romain Manni-Bucau <[email protected]>:
> Hi Andy
>
> It changes default behavior which was mainly make port unpredictable. Now it
> is almost always the same in dev which is bad IMO dince it allows to
> hardcode the port and have regular green builds locally but not on jenkins.
>
> Other point: min should be 1025 cause IIRC 1024 is reserved as well.
>
> Le 1 déc. 2014 23:06, <[email protected]> a écrit :
>
>> Repository: tomee
>> Updated Branches:
>>   refs/heads/tomee-1.7.x 1e2c844db -> 2fece229d
>>
>>
>> Just get next available port in range
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2fece229
>> Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2fece229
>> Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2fece229
>>
>> Branch: refs/heads/tomee-1.7.x
>> Commit: 2fece229d9a0312e5bc447033a5e06be2a32229c
>> Parents: 1e2c844
>> Author: andygumbrecht <[email protected]>
>> Authored: Mon Dec 1 23:05:48 2014 +0100
>> Committer: andygumbrecht <[email protected]>
>> Committed: Mon Dec 1 23:05:48 2014 +0100
>>
>> ----------------------------------------------------------------------
>>  .../src/main/java/org/apache/openejb/util/NetworkUtil.java     | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/tomee/blob/2fece229/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
>> b/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
>> index d0ce67e..40a83e9 100644
>> ---
>> a/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
>> +++
>> b/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
>> @@ -41,7 +41,7 @@ public final class NetworkUtil {
>>       * Lock file property name
>>       */
>>      public static final String TOMEE_LOCK_FILE = "TOMEE_LOCK_FILE";
>> -    public static final int[] RANDOM = new int[] { 0 };
>> +    //public static final int[] RANDOM = new int[]{0};
>>
>>      private static final ReentrantLock lock = new ReentrantLock();
>>      private static final ByteBuffer buf = ByteBuffer.allocate(512);
>> @@ -63,7 +63,7 @@ public final class NetworkUtil {
>>          final ReentrantLock l = lock;
>>          l.lock();
>>          try {
>> -            return getNextAvailablePort(RANDOM);
>> +            return getNextAvailablePort(PORT_MIN, PORT_MAX, null);
>>          } finally {
>>              l.unlock();
>>          }
>> @@ -113,7 +113,7 @@ public final class NetworkUtil {
>>                  }
>>
>>                  try {
>> -                    s = create(new int[]{ i }, lastPorts);
>> +                    s = create(new int[]{i}, lastPorts);
>>                      port = s.getLocalPort();
>>                      break;
>>
>>
>

Reply via email to