RFR : JDK-8170299 - Debugger does not stop inside the low memory notifications code

2018-07-17 Thread Harsha Wardhana B

Hi All,

Please review the fix for the bug,

JDK-8170299 - Debugger does not stop inside the low memory notifications 
code


webrev at,

http://cr.openjdk.java.net/~hb/8170299/webrev.00/

Description of the fix:

The debugger does not stop inside the listeners registered for 
notification from


1. com.sun.management.GarbageCollectorMXBean 2. sun.management.MemoryImpl 
(MemoryMXBean)
3. com.sun.management.DiagnosticCommandMBean

The listeners registered for above MBeans are invoked by 'ServiceThread' which 
is a hidden thread and is not visible to the debugger.

This issue was was already worked on before and below is the review thread for 
the same.

http://mail.openjdk.java.net/pipermail/serviceability-dev/2017-September/021782.html
http://mail.openjdk.java.net/pipermail/serviceability-dev/2017-December/022611.html

With the current fix, all the user registered callbacks for above MBeans 
are executed in a newly created SingleThreadExecutor. The above file is 
also re-factored to use CopyOnWriteArrayList for managing the listeners.


The fix has been tested in Mach5 by running all the tests under 
open/:jdk_management and closed/:jdk_management. The tests under 
open/test/jdk/java/lang/management/MemoryMXBean cover the above code 
changes. I can add more tests in the subsequent reviews if need arises.


Please review the above change and let me know your comments.

Thanks
Harsha





Re: RFR : JDK-8192953 - sun/management/jmxremote/bootstrap/*.sh tests fail with error : revokeall.exe: Permission denied

2018-06-27 Thread Harsha Wardhana B
Apart from removing revokeall.exe, all the shell scripts must be 
converted to Java programs.


I have raised JDK-8205972 to track that effort.

Harsha

On Wednesday 27 June 2018 10:38 PM, mandy chung wrote:

What refactoring are you thinking about about?

It should be straight-forward to write an utility in java to replace 
revokeall.exe.  As it has been a long-standing testing reliability 
issue and this is a test-only bug, you have time to fix in 11.


Also, your fix does not work if "open" directory does not exist.

Mandy

On 6/27/18 9:28 AM, Harsha Wardhana B wrote:
Since the tests are failing in every CI run, we have the option to 
push this fix or quarantine the tests. Refactoring the tests takes 
more than a week of effort and tests will have to be quarantined till 
then. I guess pushing this fix is the right thing to do now.


Harsha

On Wednesday 27 June 2018 09:52 PM, mandy chung wrote:
I think the right thing to do is to bite the bullet and fix the test 
properly.


In addition, this fix does not seem to work if there is no "open" 
directory.


Mandy

On 6/27/18 9:03 AM, Harsha Wardhana B wrote:
That will be done subsequently and tracked under a different bug. 
Don't you think pushing this fix is better than quarantining the 
tests?


Harsha

On Wednesday 27 June 2018 08:50 PM, mandy chung wrote:
I would suggest to take the time and replace it with java.nio.file 
API and remove revokeall.exe sooner rather than later.


Mandy

On 6/26/18 7:09 AM, Harsha Wardhana B wrote:

Hi All,

Please find the fix for the bug,

https://bugs.openjdk.java.net/browse/JDK-8192953

having webrev at,

http://cr.openjdk.java.net/~hb/8192953/webrev.00/

The fix grants execute permission for revokeall.exe. The paths in 
the shell sciprt had to be converted to cygwin paths 
(/cygwin/c/... ) from windows path (C:/...). Using windows path 
was causing strange behavior in cygwin.


revokeall.exe should be removed and the above tests need to be 
refactored to use java.nio.Acl* APIs. That plan is in the near 
future, and the current fix needs to go in to stop consistent 
failures in Mach5.


Please review the above patch and provide feedback if any.

Thanks
Harsha









Re: RFR : JDK-8192953 - sun/management/jmxremote/bootstrap/*.sh tests fail with error : revokeall.exe: Permission denied

2018-06-27 Thread Harsha Wardhana B
Since the tests are failing in every CI run, we have the option to push 
this fix or quarantine the tests. Refactoring the tests takes more than 
a week of effort and tests will have to be quarantined till then. I 
guess pushing this fix is the right thing to do now.


Harsha

On Wednesday 27 June 2018 09:52 PM, mandy chung wrote:
I think the right thing to do is to bite the bullet and fix the test 
properly.


In addition, this fix does not seem to work if there is no "open" 
directory.


Mandy

On 6/27/18 9:03 AM, Harsha Wardhana B wrote:
That will be done subsequently and tracked under a different bug. 
Don't you think pushing this fix is better than quarantining the tests?


Harsha

On Wednesday 27 June 2018 08:50 PM, mandy chung wrote:
I would suggest to take the time and replace it with java.nio.file 
API and remove revokeall.exe sooner rather than later.


Mandy

On 6/26/18 7:09 AM, Harsha Wardhana B wrote:

Hi All,

Please find the fix for the bug,

https://bugs.openjdk.java.net/browse/JDK-8192953

having webrev at,

http://cr.openjdk.java.net/~hb/8192953/webrev.00/

The fix grants execute permission for revokeall.exe. The paths in 
the shell sciprt had to be converted to cygwin paths (/cygwin/c/... 
) from windows path (C:/...). Using windows path was causing 
strange behavior in cygwin.


revokeall.exe should be removed and the above tests need to be 
refactored to use java.nio.Acl* APIs. That plan is in the near 
future, and the current fix needs to go in to stop consistent 
failures in Mach5.


Please review the above patch and provide feedback if any.

Thanks
Harsha







Re: RFR : JDK-8192953 - sun/management/jmxremote/bootstrap/*.sh tests fail with error : revokeall.exe: Permission denied

2018-06-27 Thread Harsha Wardhana B
That will be done subsequently and tracked under a different bug. Don't 
you think pushing this fix is better than quarantining the tests?


Harsha

On Wednesday 27 June 2018 08:50 PM, mandy chung wrote:
I would suggest to take the time and replace it with java.nio.file API 
and remove revokeall.exe sooner rather than later.


Mandy

On 6/26/18 7:09 AM, Harsha Wardhana B wrote:

Hi All,

Please find the fix for the bug,

https://bugs.openjdk.java.net/browse/JDK-8192953

having webrev at,

http://cr.openjdk.java.net/~hb/8192953/webrev.00/

The fix grants execute permission for revokeall.exe. The paths in the 
shell sciprt had to be converted to cygwin paths (/cygwin/c/... ) 
from windows path (C:/...). Using windows path was causing strange 
behavior in cygwin.


revokeall.exe should be removed and the above tests need to be 
refactored to use java.nio.Acl* APIs. That plan is in the near 
future, and the current fix needs to go in to stop consistent 
failures in Mach5.


Please review the above patch and provide feedback if any.

Thanks
Harsha





RFR : JDK-8192953 - sun/management/jmxremote/bootstrap/*.sh tests fail with error : revokeall.exe: Permission denied

2018-06-26 Thread Harsha Wardhana B

Hi All,

Please find the fix for the bug,

https://bugs.openjdk.java.net/browse/JDK-8192953

having webrev at,

http://cr.openjdk.java.net/~hb/8192953/webrev.00/

The fix grants execute permission for revokeall.exe. The paths in the 
shell sciprt had to be converted to cygwin paths (/cygwin/c/... ) from 
windows path (C:/...). Using windows path was causing strange behavior 
in cygwin.


revokeall.exe should be removed and the above tests need to be 
refactored to use java.nio.Acl* APIs. That plan is in the near future, 
and the current fix needs to go in to stop consistent failures in Mach5.


Please review the above patch and provide feedback if any.

Thanks
Harsha



Re: RFR : JDK-8204661 - Show error 'Port already in use' in HashedPasswordFileTest.java

2018-06-25 Thread Harsha Wardhana B

After internal discussions, we have decided to proceed with the current fix.

Thank you Mandy, Daniel, Dan and David for the review.

Harsha

On Friday 22 June 2018 10:07 AM, Harsha Wardhana B wrote:

Hi Dan,

The utility function Utils.getFreePort gets free port by creating 
server socket with port 0. Instead of getting a free port before hand 
(via Utils.getFreePort), I am letting the JMX agent choose the free 
port. The risks associated with choosing free port has moved from test 
lib to the product.


Do you think this is something that should be handled at test-level? 
Maybe refactor the test library (Utils.getFreePort)?


Thanks
Harsha

On Thursday 21 June 2018 07:28 PM, Daniel D. Daugherty wrote:
> Port number of 0 is not handled at JMX or RMI layer. The given port 
number is passed onto the ServerSocket.

>
> 
https://docs.oracle.com/javase/10/docs/api/java/net/ServerSocket.html#%3Cinit%3E(int) 



Using a port number of 0 to get a free port has to be done very 
carefully

to avoid running into other, more difficult to find issues.

Jerry T. fix a few of these before he left us:

    JDK-8182757 JDWP: Socket Transport handshake hangs on Solaris
    https://bugs.openjdk.java.net/browse/JDK-8182757

    JDK-8178676 nsk/jvmti/AttachOnDemand/attach045 fails with Exception
    https://bugs.openjdk.java.net/browse/JDK-8178676

    JDK-8188867 
nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM004

    (and other tests) timeout do to socket problem
    https://bugs.openjdk.java.net/browse/JDK-8188867


As an example of the difficulty, I tried to fix this bug:

    JDK-8182307 Error during JRMP connection establishment
    https://bugs.openjdk.java.net/browse/JDK-8182307

and had to back out my fix because it caused a couple of tests to fail.
I'm tracking the redo here:

    JDK-8193227 [REDO] 8182307 Error during JRMP connection 
establishment

    https://bugs.openjdk.java.net/browse/JDK-8193227

and I haven't had an epiphany for how to fix it without breaking
other tests (yet) so I just decommitted it from JDK11.


I'm not saying that your current fix will be susceptible to very
intermittent hangs on Solaris. I would have to take a very close
look at it and I haven't done that yet.

Dan


On 6/21/18 2:47 AM, Harsha Wardhana B wrote:



On Thursday 21 June 2018 10:30 AM, mandy chung wrote:



On 6/20/18 1:14 AM, Harsha Wardhana B wrote:

Hi,

Please find the fix below for the bug

JDK-8204661 : Show error 'Port already in use' in 
HashedPasswordFileTest.java


having webrev at,

http://cr.openjdk.java.net/~hb/8204661/webrev.00/

The problem root-cause is discussed in the comments section of the 
bug.


The fix above lets the default agent pick a free port by passing 
'port=0' value and then reads the JMX Connector URL from Perf 
Counters.


This looks fine.  Please add this issue number to @bug.

This is interesting.  I was not aware of setting port=0 will 
auto-assign a free port.  Do you know if it was added for testing 
purpose (which I assume so)?
Port number of 0 is not handled at JMX or RMI layer. The given port 
number is passed onto the ServerSocket.


https://docs.oracle.com/javase/10/docs/api/java/net/ServerSocket.html#%3Cinit%3E(int) 





For example 
test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java 
uses jdk.testlibrary.Utils.getFreePort() to get a free port number.


Mandy

Harsha









Re: RFR : JDK-8204661 - Show error 'Port already in use' in HashedPasswordFileTest.java

2018-06-21 Thread Harsha Wardhana B

Hi Dan,

The utility function Utils.getFreePort gets free port by creating server 
socket with port 0. Instead of getting a free port before hand (via 
Utils.getFreePort), I am letting the JMX agent choose the free port. The 
risks associated with choosing free port has moved from test lib to the 
product.


Do you think this is something that should be handled at test-level? 
Maybe refactor the test library (Utils.getFreePort)?


Thanks
Harsha

On Thursday 21 June 2018 07:28 PM, Daniel D. Daugherty wrote:
> Port number of 0 is not handled at JMX or RMI layer. The given port 
number is passed onto the ServerSocket.

>
> 
https://docs.oracle.com/javase/10/docs/api/java/net/ServerSocket.html#%3Cinit%3E(int) 



Using a port number of 0 to get a free port has to be done very carefully
to avoid running into other, more difficult to find issues.

Jerry T. fix a few of these before he left us:

    JDK-8182757 JDWP: Socket Transport handshake hangs on Solaris
    https://bugs.openjdk.java.net/browse/JDK-8182757

    JDK-8178676 nsk/jvmti/AttachOnDemand/attach045 fails with Exception
    https://bugs.openjdk.java.net/browse/JDK-8178676

    JDK-8188867 
nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM004

    (and other tests) timeout do to socket problem
    https://bugs.openjdk.java.net/browse/JDK-8188867


As an example of the difficulty, I tried to fix this bug:

    JDK-8182307 Error during JRMP connection establishment
    https://bugs.openjdk.java.net/browse/JDK-8182307

and had to back out my fix because it caused a couple of tests to fail.
I'm tracking the redo here:

    JDK-8193227 [REDO] 8182307 Error during JRMP connection establishment
    https://bugs.openjdk.java.net/browse/JDK-8193227

and I haven't had an epiphany for how to fix it without breaking
other tests (yet) so I just decommitted it from JDK11.


I'm not saying that your current fix will be susceptible to very
intermittent hangs on Solaris. I would have to take a very close
look at it and I haven't done that yet.

Dan


On 6/21/18 2:47 AM, Harsha Wardhana B wrote:



On Thursday 21 June 2018 10:30 AM, mandy chung wrote:



On 6/20/18 1:14 AM, Harsha Wardhana B wrote:

Hi,

Please find the fix below for the bug

JDK-8204661 : Show error 'Port already in use' in 
HashedPasswordFileTest.java


having webrev at,

http://cr.openjdk.java.net/~hb/8204661/webrev.00/

The problem root-cause is discussed in the comments section of the 
bug.


The fix above lets the default agent pick a free port by passing 
'port=0' value and then reads the JMX Connector URL from Perf 
Counters.


This looks fine.  Please add this issue number to @bug.

This is interesting.  I was not aware of setting port=0 will 
auto-assign a free port.  Do you know if it was added for testing 
purpose (which I assume so)?
Port number of 0 is not handled at JMX or RMI layer. The given port 
number is passed onto the ServerSocket.


https://docs.oracle.com/javase/10/docs/api/java/net/ServerSocket.html#%3Cinit%3E(int) 





For example 
test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java 
uses jdk.testlibrary.Utils.getFreePort() to get a free port number.


Mandy

Harsha







Re: RFR : JDK-8204661 - Show error 'Port already in use' in HashedPasswordFileTest.java

2018-06-21 Thread Harsha Wardhana B




On Thursday 21 June 2018 10:30 AM, mandy chung wrote:



On 6/20/18 1:14 AM, Harsha Wardhana B wrote:

Hi,

Please find the fix below for the bug

JDK-8204661 : Show error 'Port already in use' in 
HashedPasswordFileTest.java


having webrev at,

http://cr.openjdk.java.net/~hb/8204661/webrev.00/

The problem root-cause is discussed in the comments section of the bug.

The fix above lets the default agent pick a free port by passing 
'port=0' value and then reads the JMX Connector URL from Perf Counters.


This looks fine.  Please add this issue number to @bug.

This is interesting.  I was not aware of setting port=0 will 
auto-assign a free port.  Do you know if it was added for testing 
purpose (which I assume so)?
Port number of 0 is not handled at JMX or RMI layer. The given port 
number is passed onto the ServerSocket.


https://docs.oracle.com/javase/10/docs/api/java/net/ServerSocket.html#%3Cinit%3E(int)



For example 
test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java uses 
jdk.testlibrary.Utils.getFreePort() to get a free port number.


Mandy

Harsha


Re: RFR : JDK-8204661 - Show error 'Port already in use' in HashedPasswordFileTest.java

2018-06-20 Thread Harsha Wardhana B

Hi David,

Thanks for the review. I have ran the tests in Mach5 10 times on each 
platform and I haven't seen any failure. I will update the bug with the 
chosen approach. Would you require a separate webrev for copyright update?


Regards
Harsha

On Wednesday 20 June 2018 05:12 PM, David Holmes wrote:

Hi Harsha,

On 20/06/2018 6:14 PM, Harsha Wardhana B wrote:

Hi,

Please find the fix below for the bug

JDK-8204661 : Show error 'Port already in use' in 
HashedPasswordFileTest.java


having webrev at,

http://cr.openjdk.java.net/~hb/8204661/webrev.00/

The problem root-cause is discussed in the comments section of the bug.

The fix above lets the default agent pick a free port by passing 
'port=0' value and then reads the JMX Connector URL from Perf Counters.


Can you update the bug report with the actual solution chosen. I find 
it interesting that I can't see any other test using this technique. 
If port=0 means the port bind can't fail then this may be the 
technique all tests should be using for reliability - though it's a 
pity there's no public API supporting reading back the URL.


Have you run the test through mach5 repeatedly to check all (Posix) 
platforms and a range of systems? You can use "--test-repeat 10" for 
example to run it 10 times on each platform.



Please review the fix above and provide comments.


The copyright needs to changed to the two year format:

* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

becomes

* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights 
reserved.


Otherwise this seems okay.

Thanks,
David


Thanks
Harsha






RFR : JDK-8204661 - Show error 'Port already in use' in HashedPasswordFileTest.java

2018-06-20 Thread Harsha Wardhana B

Hi,

Please find the fix below for the bug

JDK-8204661 : Show error 'Port already in use' in 
HashedPasswordFileTest.java


having webrev at,

http://cr.openjdk.java.net/~hb/8204661/webrev.00/

The problem root-cause is discussed in the comments section of the bug.

The fix above lets the default agent pick a free port by passing 
'port=0' value and then reads the JMX Connector URL from Perf Counters.


Please review the fix above and provide comments.

Thanks
Harsha




Re: Kerberos authentication for JMX?

2018-06-12 Thread Harsha Wardhana B

Hi Peter,

JMX agents support JAAS based authentication. The login module - 
Krb5LoginModule along with JAAS can be used to setup Kerberos-based 
authentication for JMX.


A JAAS config file for Kerberos clients could look like,

kerberosClient {
   com.sun.security.auth.module.Krb5LoginModule required
   debug=true
   useKeyTab=false
  ...
};

where the configuration options for above login module can be found at,
https://docs.oracle.com/javase/10/docs/api/com/sun/security/auth/module/Krb5LoginModule.html

The default JMX agent can be started by setting below two system properties.

1. com.sun.management.jmxremote.login.config - The JAAS entry in config 
file above

2. java.security.auth.login.config - The path to the above file

Example:

java -Dcom.sun.management.jmxremote.port=5000
 -Dcom.sun.management.jmxremote.login.config=kerberosClient
 -Djava.security.auth.login.config=kerberos.config
 -jar MyApplication.jar


I have not tried the steps above myself but should work in theory. Give 
it a try and let me know if it works.


Thanks
Harsha

On Monday 11 June 2018 06:44 PM, Péter Gergely Horváth wrote:

Hi All,

I have been working with Big Data for a while and I have seen that a 
number of the components have started to have their own custom baked 
solutions (minimalistic Web UIs) for basic management operations, like 
showing metrics, debugging etc instead of using JMX.


I have the feeling that getting JMX working for dozens of different 
Java services within a large cluster is an overly tough task, 
especially if you do not want to make compromises around security. For 
me it seems, that at the moment there is a gap between what the JDK 
offers regarding JMX monitoring/management and what people would need 
in a real world setting to use iteffectively in an easy and secure way.


I am wondering if it would be possible to implement a Kerberos-based 
authentication mechanism for JMX, allowing all services of a cluster 
to authenticate JMX clients against a centrally managed Kerberos 
service, that would also be officially supported by VisualVM so as to 
give an easy-to-use user interface.



Based on my understanding, this could either be a new protocol 
implementation or assuming JDK-8171311: REST APIs for JMX gets done, 
an additional feature around there to support GSS 
Negotiate/SPNEGO based authentication.


Could you please share your thoughts on this? Would anyone be 
interested to sponsor this topic?


Thanks,
Peter







Re: Ping!! Re: RFR: 8203357 Container Metrics

2018-06-07 Thread Harsha Wardhana B

[Replying to all mailing-lists]
Hi Misha,

The ERROR_MARGIN in tests was introduced to make the tests stable. There 
are times where metric values (specifically CPU usage) can change 
drastically in between two reads. The metrics value got from the API and 
the cgroup file can be different and 0.1 ERROR_MARGIN should take care 
of that, though at times even that may not be enough. Hence the CPU 
usage related tests only print a warning if ERROR_MARGIN is exceeded.


Thanks
Harsha

On Friday 08 June 2018 03:00 AM, Mikhailo Seledtsov wrote:

Hi Bob,

  I looked at the tests. In general they look good. I am a bit 
concerned about the use of ERROR_MARGIN in one of the tests. We need 
to make sure that the tests are stable, and do not produce 
intermittent failures.



Thank you,
Misha

On 6/7/18, 10:43 AM, Bob Vandette wrote:

Can I get one more reviewer for this RFE so I can integrate it?


http://cr.openjdk.java.net/~bobv/8203357/webrev.01

Mandy Chung has reviewed this change.

I’ve run Mach5 hotspot and core lib tests.

I’ve reviewed the tests which were written by Harsha Wardhana

I filed a CSR for the command line change and it’s now approved and 
closed.


Thanks,
Bob.


On May 30, 2018, at 3:45 PM, Bob Vandette  
wrote:


Please review the following RFE which adds an internal API, along 
with jtreg tests that provide
access to Docker container configuration data and metrics.  In 
addition to the API which we hope to
take advantage of in the future with Java Flight Recorder and a JMX 
Mbean, I’ve added an additional
option to -XshowSettings:system than dumps out the container or host 
cgroup confguration

information.  See the sample output below:

RFE: Container Metrics

https://bugs.openjdk.java.net/browse/JDK-8203357

WEBREV:

http://cr.openjdk.java.net/~bobv/8203357/webrev.01


This commit will also include a fix for the following bug.

BUG: [TESTBUG] Test /runtime/containers/cgroup/PlainRead.java fails

https://bugs.openjdk.java.net/browse/JDK-8203691

WEBREV:

http://cr.openjdk.java.net/~bobv/8203357/webrev.00/test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java.sdiff.html 



SAMPLE USAGE and OUTPUT:

docker run —memory=256m --cpuset-cpus 4-7 -it ubuntu bash
./java -XshowSettings:system
Operating System Metrics:
    Provider: cgroupv1
    Effective CPU Count: 4
    CPU Period: 10
    CPU Quota: -1
    CPU Shares: -1
    List of Processors, 4 total:
    4 5 6 7
    List of Effective Processors, 4 total:
    4 5 6 7
    List of Memory Nodes, 2 total:
    0 1
    List of Available Memory Nodes, 2 total:
    0 1
    CPUSet Memory Pressure Enabled: false
    Memory Limit: 256.00M
    Memory Soft Limit: Unlimited
    Memory&  Swap Limit: 512.00M
    Kernel Memory Limit: Unlimited
    TCP Memory Limit: Unlimited
    Out Of Memory Killer Enabled: true

TEST RESULTS:

testing runtime container APIs
Directory "JTwork" not found: creating
Passed: runtime/containers/cgroup/PlainRead.java
Passed: runtime/containers/docker/DockerBasicTest.java
Passed: runtime/containers/docker/TestCPUAwareness.java
Passed: runtime/containers/docker/TestCPUSets.java
Passed: runtime/containers/docker/TestMemoryAwareness.java
Passed: runtime/containers/docker/TestMisc.java
Test results: passed: 6
Results written to /export/users/bobv/jdk11/build/jtreg/JTwork

testing jdk.internal.platform APIs
Passed: jdk/internal/platform/cgroup/TestCgroupMetrics.java
Passed: jdk/internal/platform/docker/TestDockerCpuMetrics.java
Passed: jdk/internal/platform/docker/TestDockerMemoryMetrics.java
Passed: jdk/internal/platform/docker/TestSystemMetrics.java
Test results: passed: 4
Results written to /export/users/bobv/jdk11/build/jtreg/JTwork

testing -XshowSettings:system launcher option
Passed: tools/launcher/Settings.java
Test results: passed: 1


Bob.






Re: Ping!! Re: RFR: 8203357 Container Metrics

2018-06-07 Thread Harsha Wardhana B

Hi Misha,

The ERROR_MARGIN in tests was introduced to make the tests stable. There 
are times where metric values (specifically CPU usage) can change 
drastically in between two reads. The metrics value got from the API and 
the cgroup file can be different and 0.1 ERROR_MARGIN should take care 
of that, though at times even that may not be enough. Hence the CPU 
usages related the tests only print a warning if ERROR_MARGIN is exceeded.


Thanks
Harsha

On Friday 08 June 2018 03:00 AM, Mikhailo Seledtsov wrote:

Hi Bob,

  I looked at the tests. In general they look good. I am a bit 
concerned about the use of ERROR_MARGIN in one of the tests. We need 
to make sure that the tests are stable, and do not produce 
intermittent failures.



Thank you,
Misha

On 6/7/18, 10:43 AM, Bob Vandette wrote:

Can I get one more reviewer for this RFE so I can integrate it?


http://cr.openjdk.java.net/~bobv/8203357/webrev.01

Mandy Chung has reviewed this change.

I’ve run Mach5 hotspot and core lib tests.

I’ve reviewed the tests which were written by Harsha Wardhana

I filed a CSR for the command line change and it’s now approved and 
closed.


Thanks,
Bob.


On May 30, 2018, at 3:45 PM, Bob Vandette  
wrote:


Please review the following RFE which adds an internal API, along 
with jtreg tests that provide
access to Docker container configuration data and metrics.  In 
addition to the API which we hope to
take advantage of in the future with Java Flight Recorder and a JMX 
Mbean, I’ve added an additional
option to -XshowSettings:system than dumps out the container or host 
cgroup confguration

information.  See the sample output below:

RFE: Container Metrics

https://bugs.openjdk.java.net/browse/JDK-8203357

WEBREV:

http://cr.openjdk.java.net/~bobv/8203357/webrev.01


This commit will also include a fix for the following bug.

BUG: [TESTBUG] Test /runtime/containers/cgroup/PlainRead.java fails

https://bugs.openjdk.java.net/browse/JDK-8203691

WEBREV:

http://cr.openjdk.java.net/~bobv/8203357/webrev.00/test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java.sdiff.html 



SAMPLE USAGE and OUTPUT:

docker run —memory=256m --cpuset-cpus 4-7 -it ubuntu bash
./java -XshowSettings:system
Operating System Metrics:
    Provider: cgroupv1
    Effective CPU Count: 4
    CPU Period: 10
    CPU Quota: -1
    CPU Shares: -1
    List of Processors, 4 total:
    4 5 6 7
    List of Effective Processors, 4 total:
    4 5 6 7
    List of Memory Nodes, 2 total:
    0 1
    List of Available Memory Nodes, 2 total:
    0 1
    CPUSet Memory Pressure Enabled: false
    Memory Limit: 256.00M
    Memory Soft Limit: Unlimited
    Memory&  Swap Limit: 512.00M
    Kernel Memory Limit: Unlimited
    TCP Memory Limit: Unlimited
    Out Of Memory Killer Enabled: true

TEST RESULTS:

testing runtime container APIs
Directory "JTwork" not found: creating
Passed: runtime/containers/cgroup/PlainRead.java
Passed: runtime/containers/docker/DockerBasicTest.java
Passed: runtime/containers/docker/TestCPUAwareness.java
Passed: runtime/containers/docker/TestCPUSets.java
Passed: runtime/containers/docker/TestMemoryAwareness.java
Passed: runtime/containers/docker/TestMisc.java
Test results: passed: 6
Results written to /export/users/bobv/jdk11/build/jtreg/JTwork

testing jdk.internal.platform APIs
Passed: jdk/internal/platform/cgroup/TestCgroupMetrics.java
Passed: jdk/internal/platform/docker/TestDockerCpuMetrics.java
Passed: jdk/internal/platform/docker/TestDockerMemoryMetrics.java
Passed: jdk/internal/platform/docker/TestSystemMetrics.java
Test results: passed: 4
Results written to /export/users/bobv/jdk11/build/jtreg/JTwork

testing -XshowSettings:system launcher option
Passed: tools/launcher/Settings.java
Test results: passed: 1


Bob.






Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-04-27 Thread Harsha Wardhana B



On Thursday 26 April 2018 09:09 PM, mandy chung wrote:



On 4/23/18 1:20 PM, Harsha Wardhana B wrote:

Hi All,

After internal discussions, many of the concerns below were addressed 
and final spec is published at,


https://bugs.openjdk.java.net/browse/JDK-8199584

Below is the implementation of the above spec.

http://cr.openjdk.java.net/~hb/8187498/webrev.05/


src/java.base/share/classes/sun/launcher/resources/launcher.properties
112 \ --start-management-agent option=value[:option=value:]\n\

option and value should be  and  to represent user-supplied 
name/value.

The syntax used is borrowed from Java tool guide,

https://docs.oracle.com/javase/10/tools/java.htm#JSWOR624

It is also part of java -help output which has been already approved in 
the CSR.

  113 \ start the default management agent with semi-colon separated\n\
  114 \ list of options. Multiple values for an option should be 
separated\n\

115 \ by comma. See the java tool guide for a list of options for\n\
116 \ the default management agent.\n\ typo: "semi-colon separated 
list" should be colon-separated list "See the java tool guide" - 
should be "See the Java Monitoring and Management Guide for details"
I will fix the typo. But the extended help for java is part of the tool 
guide and not part of management guide. Hence I would like to keep the 
original reference to tool guide.
src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java I 
think the change from single class import to import java.util.* and 
java.io.* may not be done intentionally (I guess it might be done by 
IDE). I prefer to keep the orginal single class import.

ok.


665 if (args.equals("--start-management-agent") || 
args.equals("--start-management-agent=")) { 666 // Options are 
mandatory 667 error(INVALID_OPTION, args); 668 }
709 Optional argStr = vmArguments.stream() 710 .filter(a -> 
a.startsWith("--start-management-agent")) 711 .reduce((a, b) -> b); 
The only form passed to the VM is --start-management-agent= since 
VM option does not take white-space separated argument. I think line 
666 and 710 should check for "--start-management-agent=" only.

ok
676 String minusDflag = managementFlags.get(name); minusDflag can be 
renamed to "propertyName" which is clearer.

ok
714 props.forEach((a, b) -> { 715 String oldVaue = 
System.getProperty((String) a); 716 if (oldVaue != null && 
!oldVaue.isEmpty()) { 717 error(INVALID_OPTION, "management options 
can be set via -D flags or via --start-management-agent but not 
both"); 718 } 719 System.setProperty((String) a, (String) b); 720 }); 
721 }  714 props.forEach((a, b) -> {

715 String oldVaue = System.getProperty((String) a);
716 if (oldVaue != null && !oldVaue.isEmpty()) {
717 error(INVALID_OPTION, "management options can be set via -D flags 
or via --start-management-agent but not both");

718 }
I think checking if -D is set should be done for each constant defined 
in ConnectorBootstrap.PropertyNames class instead of each key in props 
since it could set -Dcom.sun.management.jmxremote.port it didn't set 
port in --start-management-agent. Do you have such test case covered?

Agreed. I will modify the code and add a test case to validate the changes.
  719 System.setProperty((String) a, (String) b);I don't expect 
--start-management-agent will set the system properties like if 
-Dcom.sun.management.config.file=config.file which will not set 
additional system properties, right? It's also not specified in CSR. I see the existing code calling System.getProperty is not modified.  I think

that may need to be updated too?

I did not understand. Can you please elaborate.

In addition, as specified in CSR, e.e.g

--start-management-agent 
port=1234:configFile=management.properties:ssl=true:authenticate=false

The value specified via the command line takes precedence over the value
specified in the config file.  port=1234 and ssl=true will take precedence
even if those properties are set in management.properties.

It seems that this is not covered (or I missed it from the webrev).
That is a default behavior for all command line flags and hence not part 
of the webrev.

ConnectorBootstrap.PropertyNames  defines the property names.  It may be
better to extend this class to take the short name and value validator
into account (replace the managementMap and validatorMap).  You may
want to refactor it out as an outer class if needed.


ConnectorBootstrap.PropertyNames is heavily used in sources as well as 
tests and hence it is not straight-forward to re factor it. I have used 
the constants from the latter instead of raw strings for managementMap.

I will review the test when the webrev is updated (in case the test will
need update).

Mandy


Thanks
Harsha



Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-04-22 Thread Harsha Wardhana B

Hi All,

After internal discussions, many of the concerns below were addressed 
and final spec is published at,


https://bugs.openjdk.java.net/browse/JDK-8199584

Below is the implementation of the above spec.

http://cr.openjdk.java.net/~hb/8187498/webrev.05/

Please review and provide feedback.

Thanks
Harsha

On Wednesday 21 February 2018 08:33 PM, Roger Riggs wrote:

Hi,

I'm a bit leary of command line arguments being special cased and the 
corresponding custom
mappings to system properties.   The convenience is fine but we need 
to keep the handling
out of native code so it is easier to maintain.  We don't have a Java 
API for processing

(VM) command line arguments so they are being shoehorned into properties.

$.02, Roger

On 2/21/2018 12:55 AM, Harsha Wardhana B wrote:



On Wednesday 21 February 2018 01:51 AM, mandy chung wrote:

The code review and CSR review can be in parallel.  For this case,
I agree with Kumar to have CSR written that would help the code
review. Please specify the behavior and its relationship with
jcmd and other relevant diagnosability tools.

ok.


On 2/20/18 6:41 AM, Kumar Srinivasan wrote:


What is the behavior when 
-Dcom.sun.management.jmxremote.port=1234 
--start-management-agent port=2345 
-Dcom.sun.management.jmxremote.port=3456?


What is the value of the system property 
com.sun.management.jmxremote.port at runtime?  What port number 
does the management server start with?
As said earlier, values set via new flags override values set by 
-D flags. So 2345 will be the value of 
com.sun.management.jmxremote.port. Added a test case to validate 
that.


VM options are the last one wins if same option specified multiple 
times.  In this case, it could cause confusion (the last -D option 
sets the value to 3456 but it's set to a different value).


Why not taking the simplest approach - when --start-management-agent 
is set, it does not accept mixing the old way (i.e. does not accept 
the management properties to be set via -D)?   This RFE is to make 
the command-line simpler and ease-of-use.  I don't see any downside 
to migrate entirely to the new form.
We cannot get rid of specifying options via -D. We have plenty of -D 
flags but very few have short-hand alternative via 
--start-management-agent. If management properties are specified by 
--start-management-agent, the options specified by -D are anyway 
overwritten if specified.


Mandy

Harsha






Re: RFR : JDK-8196744 : JMX: Not enough JDP packets received before timeout

2018-03-19 Thread Harsha Wardhana B

Thanks David.

-Harsha

On Tuesday 20 March 2018 02:13 AM, David Holmes wrote:

Hi Harsha,

Given the negative nature of the test this approach seems quite 
reasonable.


Thanks,
David


Harsha Wardhana B <harsha.wardhan...@oracle.com>
Ping! Can I have one more review for the below fix?

Thanks

Harsha

On Monday 26 February 2018 10:42 AM, Harsha Wardhana B wrote:


Hello All,







Requesting for review from one more reviewer.







Thanks



Harsha







On Wednesday 21 February 2018 10:01 AM, Chris Plummer wrote:



Hi Harsha,






Not a review, but just a request that you add the explanation of the 


problem to the CR so we have a record of it. Also, the copyright 



needs to be updated.







thanks,







Chris







On 2/20/18 3:30 AM, Harsha Wardhana B wrote:



Hi All,







Please find the fix below for the Jdp test-case.







issue: https://bugs.openjdk.java.net/browse/JDK-8196028



webrev : http://cr.openjdk.java.net/~hb/8196028/webrev.00/






Fix details : The test was receiving JDP packets from other VM and 


hence the multi-cast socket was not timing-out. The default timeout 


handler was causing test to fail. Added a shutdown method that 



passes the test in case of timeout.







Thanks



Harsha


















Re: RFR : JDK-8196744 : JMX: Not enough JDP packets received before timeout

2018-03-11 Thread Harsha Wardhana B

Ping! Can I have one more review for the below fix?

Thanks
Harsha

On Monday 26 February 2018 10:42 AM, Harsha Wardhana B wrote:

Hello All,

Requesting for review from one more reviewer.

Thanks
Harsha

On Wednesday 21 February 2018 10:01 AM, Chris Plummer wrote:

Hi Harsha,

Not a review, but just a request that you add the explanation of the 
problem to the CR so we have a record of it. Also, the copyright 
needs to be updated.


thanks,

Chris

On 2/20/18 3:30 AM, Harsha Wardhana B wrote:

Hi All,

Please find the fix below for the Jdp test-case.

issue: https://bugs.openjdk.java.net/browse/JDK-8196028
webrev : http://cr.openjdk.java.net/~hb/8196028/webrev.00/

Fix details : The test was receiving JDP packets from other VM and 
hence the multi-cast socket was not timing-out. The default timeout 
handler was causing test to fail. Added a shutdown method that 
passes the test in case of timeout.


Thanks
Harsha









Re: RFR : JDK-8196744 : JMX: Not enough JDP packets received before timeout

2018-02-25 Thread Harsha Wardhana B

Hello All,

Requesting for review from one more reviewer.

Thanks
Harsha

On Wednesday 21 February 2018 10:01 AM, Chris Plummer wrote:

Hi Harsha,

Not a review, but just a request that you add the explanation of the 
problem to the CR so we have a record of it. Also, the copyright needs 
to be updated.


thanks,

Chris

On 2/20/18 3:30 AM, Harsha Wardhana B wrote:

Hi All,

Please find the fix below for the Jdp test-case.

issue: https://bugs.openjdk.java.net/browse/JDK-8196028
webrev : http://cr.openjdk.java.net/~hb/8196028/webrev.00/

Fix details : The test was receiving JDP packets from other VM and 
hence the multi-cast socket was not timing-out. The default timeout 
handler was causing test to fail. Added a shutdown method that passes 
the test in case of timeout.


Thanks
Harsha







Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-21 Thread Harsha Wardhana B



On Wednesday 21 February 2018 09:51 PM, mandy chung wrote:



On 2/20/18 9:55 PM, Harsha Wardhana B wrote:


We cannot get rid of specifying options via -D. We have plenty of -D 
flags but very few have short-hand alternative via 
--start-management-agent. If management properties are specified by 
--start-management-agent, the options specified by -D are anyway 
overwritten if specified.


I have to see the specification of this feature and give further 
feedback.   If the new option does not accept all management 
properties, what is the benefit of this new option?
The new options makes it easy to start and configure default agent. As 
of now, users needs to be aware of -D flags which are long and 
cumbersome. Hence only most frequently used -D flags are given the 
short-hand alternative to --start-management-agent.


Harsha


Mandy




Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-20 Thread Harsha Wardhana B



On Wednesday 21 February 2018 01:51 AM, mandy chung wrote:

The code review and CSR review can be in parallel.  For this case,
I agree with Kumar to have CSR written that would help the code
review. Please specify the behavior and its relationship with
jcmd and other relevant diagnosability tools.

ok.


On 2/20/18 6:41 AM, Kumar Srinivasan wrote:


What is the behavior when -Dcom.sun.management.jmxremote.port=1234 
--start-management-agent port=2345 
-Dcom.sun.management.jmxremote.port=3456?


What is the value of the system property 
com.sun.management.jmxremote.port at runtime?  What port number 
does the management server start with?
As said earlier, values set via new flags override values set by -D 
flags. So 2345 will be the value of 
com.sun.management.jmxremote.port. Added a test case to validate that.


VM options are the last one wins if same option specified multiple 
times.  In this case, it could cause confusion (the last -D option 
sets the value to 3456 but it's set to a different value).


Why not taking the simplest approach - when --start-management-agent 
is set, it does not accept mixing the old way (i.e. does not accept 
the management properties to be set via -D)?   This RFE is to make the 
command-line simpler and ease-of-use.  I don't see any downside to 
migrate entirely to the new form.
We cannot get rid of specifying options via -D. We have plenty of -D 
flags but very few have short-hand alternative via 
--start-management-agent. If management properties are specified by 
--start-management-agent, the options specified by -D are anyway 
overwritten if specified.


Mandy

Harsha


Re: RFR : JDK-8196028 : JMX: Not enough JDP packets received before timeout

2018-02-20 Thread Harsha Wardhana B

[Correcting bug Id in the subject]

Thanks Erik.

Harsha

On Tuesday 20 February 2018 08:44 PM, Erik Gahlin wrote:

Looks OK.

Erik


Hi All,

Please find the fix below for the Jdp test-case.

issue: https://bugs.openjdk.java.net/browse/JDK-8196028
webrev : http://cr.openjdk.java.net/~hb/8196028/webrev.00/

Fix details : The test was receiving JDP packets from other VM and 
hence the multi-cast socket was not timing-out. The default timeout 
handler was causing test to fail. Added a shutdown method that passes 
the test in case of timeout.


Thanks
Harsha






Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-20 Thread Harsha Wardhana B

Ping. Could I please have reviews for below webrev.

Thanks
Harsha

On Wednesday 14 February 2018 09:59 PM, Harsha Wardhana B wrote:

Hi,

Below is the updated webrev.

http://cr.openjdk.java.net/~hb/8187498/webrev.03/


On Wednesday 14 February 2018 01:15 AM, mandy chung wrote:



On 2/13/18 1:30 AM, Harsha Wardhana B wrote:

Hi,

Please find below the revised webrev.

http://cr.openjdk.java.net/~hb/8187498/webrev.02/


On Friday 09 February 2018 05:07 AM, mandy chung wrote:

On 2/7/18 1:19 AM, Harsha Wardhana B wrote:
> 
> --start-management-agent will not be recognized in the current format and

> hence will not default to --start-management-agent=local=true.

`--start-local-management-server` is one option as Alan suggests.
Another option is to make `--start-management-agent` to accept
an optional argument.  VM can accept `--start-management-agent`
or `--start-management-agent=port=1234,ssl=on`.  It may require
more launcher change to support it.
Yes. It requires lot more changes to launcher. Hence optional 
argument to --start-management-agent was not added in order to keep 
the launcher impact minimum.


This is just one option for you to consider.   So the current 
proposal of the new option to start a remote management server, right?
Not necessarily. --start-management-agent=local=true starts local 
server and --start-management-agent=port=1234 starts remote management 
server.

Agent.java
  If --start-management-agent is set, -Dcom.sun.management.* takes
  precedence.  Do you really want to do that?  The new VM option
  intends to simplify the command-line to type in.  I think it's
  cleaner and reasonable if --start-management-agent is specified,
  -Dcom.sun.management.* are ignored (maybe worth emit a warning if set)
We can probably document that -D options will be overridden instead 
of emitting a warning.


What is the behavior when -Dcom.sun.management.jmxremote.port=1234 
--start-management-agent port=2345 
-Dcom.sun.management.jmxremote.port=3456?


What is the value of the system property 
com.sun.management.jmxremote.port at runtime?  What port number does 
the management server start with?
As said earlier, values set via new flags override values set by -D 
flags. So 2345 will be the value of com.sun.management.jmxremote.port. 
Added a test case to validate that.



  The implementation uses VMManagement::getVmArguments and scan
  the VM options for -start-management-agent.  The VM is the one
  invoking jdk.internal.agent.Agent::startAgent.  A simpler option
  is to change Agent::startAgent to take an argument parameter
  that will be passed with the argument of --start-management-agent
  or null if not set.

  Similarly for startRemoteManagementAgent and startLocalAgent_name.
Implementing this change requires lot of changes to argument parsing 
in native code and hence it is simpler to handle this at java layer.


Can you describe how --start-management-agent option will be used for 
jcmd and any other tool that attaches to a running VM to start the 
agent?  Example command-line will be useful.
--start-management-agent cannot be used by jcmd (or dynamic attach) as 
it accepts flags only in -D format or -D flags with com.sun.management 
removed. That code to parse string passed via jcmd was a mistake and 
hence I have removed it.



Mandy

-Harsha




RFR : JDK-8196744 : JMX: Not enough JDP packets received before timeout

2018-02-20 Thread Harsha Wardhana B

Hi All,

Please find the fix below for the Jdp test-case.

issue: https://bugs.openjdk.java.net/browse/JDK-8196028
webrev : http://cr.openjdk.java.net/~hb/8196028/webrev.00/

Fix details : The test was receiving JDP packets from other VM and hence 
the multi-cast socket was not timing-out. The default timeout handler 
was causing test to fail. Added a shutdown method that passes the test 
in case of timeout.


Thanks
Harsha


Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-14 Thread Harsha Wardhana B

Hi,

Below is the updated webrev.

http://cr.openjdk.java.net/~hb/8187498/webrev.03/


On Wednesday 14 February 2018 01:15 AM, mandy chung wrote:



On 2/13/18 1:30 AM, Harsha Wardhana B wrote:

Hi,

Please find below the revised webrev.

http://cr.openjdk.java.net/~hb/8187498/webrev.02/


On Friday 09 February 2018 05:07 AM, mandy chung wrote:

On 2/7/18 1:19 AM, Harsha Wardhana B wrote:
> 
> --start-management-agent will not be recognized in the current format and

> hence will not default to --start-management-agent=local=true.

`--start-local-management-server` is one option as Alan suggests.
Another option is to make `--start-management-agent` to accept
an optional argument.  VM can accept `--start-management-agent`
or `--start-management-agent=port=1234,ssl=on`.  It may require
more launcher change to support it.
Yes. It requires lot more changes to launcher. Hence optional 
argument to --start-management-agent was not added in order to keep 
the launcher impact minimum.


This is just one option for you to consider.   So the current proposal 
of the new option to start a remote management server, right?
Not necessarily. --start-management-agent=local=true starts local server 
and --start-management-agent=port=1234 starts remote management server.

Agent.java
  If --start-management-agent is set, -Dcom.sun.management.* takes
  precedence.  Do you really want to do that?  The new VM option
  intends to simplify the command-line to type in.  I think it's
  cleaner and reasonable if --start-management-agent is specified,
  -Dcom.sun.management.* are ignored (maybe worth emit a warning if set)
We can probably document that -D options will be overridden instead 
of emitting a warning.


What is the behavior when -Dcom.sun.management.jmxremote.port=1234 
--start-management-agent port=2345 
-Dcom.sun.management.jmxremote.port=3456?


What is the value of the system property 
com.sun.management.jmxremote.port at runtime?  What port number does 
the management server start with?
As said earlier, values set via new flags override values set by -D 
flags. So 2345 will be the value of com.sun.management.jmxremote.port. 
Added a test case to validate that.



  The implementation uses VMManagement::getVmArguments and scan
  the VM options for -start-management-agent.  The VM is the one
  invoking jdk.internal.agent.Agent::startAgent.  A simpler option
  is to change Agent::startAgent to take an argument parameter
  that will be passed with the argument of --start-management-agent
  or null if not set.

  Similarly for startRemoteManagementAgent and startLocalAgent_name.
Implementing this change requires lot of changes to argument parsing 
in native code and hence it is simpler to handle this at java layer.


Can you describe how --start-management-agent option will be used for 
jcmd and any other tool that attaches to a running VM to start the 
agent?  Example command-line will be useful.
--start-management-agent cannot be used by jcmd (or dynamic attach) as 
it accepts flags only in -D format or -D flags with com.sun.management 
removed. That code to parse string passed via jcmd was a mistake and 
hence I have removed it.



Mandy

-Harsha


Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-13 Thread Harsha Wardhana B

Hi,

Please find below the revised webrev.

http://cr.openjdk.java.net/~hb/8187498/webrev.02/


On Friday 09 February 2018 05:07 AM, mandy chung wrote:

On 2/7/18 1:19 AM, Harsha Wardhana B wrote:
> 
> --start-management-agent will not be recognized in the current format and

> hence will not default to --start-management-agent=local=true.

`--start-local-management-server` is one option as Alan suggests.
Another option is to make `--start-management-agent` to accept
an optional argument.  VM can accept `--start-management-agent`
or `--start-management-agent=port=1234,ssl=on`.  It may require
more launcher change to support it.
Yes. It requires lot more changes to launcher. Hence optional argument 
to --start-management-agent was not added in order to keep the launcher 
impact minimum.

> Below is the webrev with above changes and corresponding tests.
>
> http://cr.openjdk.java.net/~hb/8187498/webrev.01/

arguments.cpp

3216 if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != 
Flag::SUCCESS) {
3217   return JNI_EINVAL;
3218 }
3219 // management agent in module jdk.management.agent
3220 if (!create_numbered_property("jdk.module.addmods", 
"jdk.management.agent", addmods_count++)) {
3221   return JNI_ENOMEM;
3222 }

- you can consider refactor this to replace this block and line 2988-3994.

3224 jio_fprintf(defaultStream::output_stream(),
3225   "-Xmanagement is not supported in this VM.\n");

-Xmanagement not yet renamed
java.c
   To set the precedence for future VM long form options, I suggest to
rename IsManagementOption to IsVMLongFormOption and change the error
message not specific to management agent.

Incorporated above changes.

Agent.java
  If --start-management-agent is set, -Dcom.sun.management.* takes
  precedence.  Do you really want to do that?  The new VM option
  intends to simplify the command-line to type in.  I think it's
  cleaner and reasonable if --start-management-agent is specified,
  -Dcom.sun.management.* are ignored (maybe worth emit a warning if set)
We can probably document that -D options will be overridden instead of 
emitting a warning.

  The implementation uses VMManagement::getVmArguments and scan
  the VM options for -start-management-agent.  The VM is the one
  invoking jdk.internal.agent.Agent::startAgent.  A simpler option
  is to change Agent::startAgent to take an argument parameter
  that will be passed with the argument of --start-management-agent
  or null if not set.

  Similarly for startRemoteManagementAgent and startLocalAgent_name.
Implementing this change requires lot of changes to argument parsing in 
native code and hence it is simpler to handle this at java layer.

  parseXmgmtArgs should be renamed as no longer -Xmgmt. Better not
  to tightly coupled with the option name.

Ok.

  291 if(args.startsWith("--start-management-agent")) {
  292 return parseXmgmtArgs(args);
  293 }

What is this change for?

This is required when management agent is started via attach mechanism.

Mandy

-Harsha


Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-07 Thread Harsha Wardhana B

Hi Kumar,

Thanks for your inputs.

On Wednesday 07 February 2018 09:02 PM, Kumar Srinivasan wrote:


Hi Harsha,

Changes look reasonable to me, couple of things that must be addressed:

1. Since this is a main-stream launcher change with a documented and 
supported
option, a CSR is required,  you have  to add and document the option 
in the help page
http://hg.openjdk.java.net/jdk/jdk/file/8cc67294ec56/src/java.base/share/classes/sun/launcher/resources/launcher.properties 



2. You also have to create a doc bug so that the doc team will 
document it in the Tools
Reference Guide, and link it to this bug. Does it need a Release note 
? probably does,
in which case you will have to create Release Note subtask and follow 
the RN process.

Will take care of above items.


3. Is XmanagementAgentTest.java part of tier1 test suite ? If not, 
then  I think it ought
to be in tier1 grouping, perhaps best to park this under 
jdk/tools/launcher/management ?

Ok. I will move the test in subsequent webrev.

-Harsha



Kumar



Hi All,

After internal discussions, below format for management flags was 
agreed upon.


1. --start-management-agent port=1234,ssl=on    (space seperator)
or
2. --start-management-agent=port=1234,ssl=on    ('=' seperator)

If option 1 is specified, it will be converted to option 2 by the 
java launcher before it is passed onto VM.


With above GNU long format for management options, specifying 
arguments is mandatory unlike before.


--start-management-agent will not be recognized in the current format 
and hence will not default to --start-management-agent=local=true.


Below is the webrev with above changes and corresponding tests.

http://cr.openjdk.java.net/~hb/8187498/webrev.01/

Please review and comment.

Thanks
Harsha

On Monday 29 January 2018 03:14 PM, Harsha Wardhana B wrote:

Hi Alan,

I am not fully aware about Java launcher or how it passes options to 
VM. Let me check with some other folks and get back to you.


Thanks
Harsha

On Monday 29 January 2018 01:55 PM, Alan Bateman wrote:



On 29/01/2018 05:20, Harsha Wardhana B wrote:

Hi Mandy,Alan,

Thanks for your inputs.
If I keep it as launcher option, it may need to know JMX agent 
flags which may need to be extended in future.
I would prefer making it a VM option. I will make the required 
changes and send out an updated webrev.
I think Mandy's suggestion is to just transform --management 
 so a form that the VM can read. The launcher will need to 
replace the space anyway as the VM only accepts "=".


-Alan










Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-02-07 Thread Harsha Wardhana B

Hi All,

After internal discussions, below format for management flags was agreed 
upon.


1. --start-management-agent port=1234,ssl=on        (space seperator)
or
2. --start-management-agent=port=1234,ssl=on        ('=' seperator)

If option 1 is specified, it will be converted to option 2 by the java 
launcher before it is passed onto VM.


With above GNU long format for management options, specifying arguments 
is mandatory unlike before.


--start-management-agent will not be recognized in the current format 
and hence will not default to --start-management-agent=local=true.


Below is the webrev with above changes and corresponding tests.

http://cr.openjdk.java.net/~hb/8187498/webrev.01/

Please review and comment.

Thanks
Harsha

On Monday 29 January 2018 03:14 PM, Harsha Wardhana B wrote:

Hi Alan,

I am not fully aware about Java launcher or how it passes options to 
VM. Let me check with some other folks and get back to you.


Thanks
Harsha

On Monday 29 January 2018 01:55 PM, Alan Bateman wrote:



On 29/01/2018 05:20, Harsha Wardhana B wrote:

Hi Mandy,Alan,

Thanks for your inputs.
If I keep it as launcher option, it may need to know JMX agent flags 
which may need to be extended in future.
I would prefer making it a VM option. I will make the required 
changes and send out an updated webrev.
I think Mandy's suggestion is to just transform --management 
 so a form that the VM can read. The launcher will need to 
replace the space anyway as the VM only accepts "=".


-Alan






Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-01-29 Thread Harsha Wardhana B

Hi Alan,

I am not fully aware about Java launcher or how it passes options to VM. 
Let me check with some other folks and get back to you.


Thanks
Harsha

On Monday 29 January 2018 01:55 PM, Alan Bateman wrote:



On 29/01/2018 05:20, Harsha Wardhana B wrote:

Hi Mandy,Alan,

Thanks for your inputs.
If I keep it as launcher option, it may need to know JMX agent flags 
which may need to be extended in future.
I would prefer making it a VM option. I will make the required 
changes and send out an updated webrev.
I think Mandy's suggestion is to just transform --management  
so a form that the VM can read. The launcher will need to replace the 
space anyway as the VM only accepts "=".


-Alan




Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-01-28 Thread Harsha Wardhana B

Hi Mandy,Alan,

Thanks for your inputs.
If I keep it as launcher option, it may need to know JMX agent flags 
which may need to be extended in future.
I would prefer making it a VM option. I will make the required changes 
and send out an updated webrev.


-Harsha

On Thursday 25 January 2018 09:31 PM, mandy chung wrote:

Hi Harsha,

JEP 293 [1] describes the guidelines for JDK command-line options.  As 
Alan points out, new options should move away from -X prefix but use 
`--` GNU-style long form option.  The guideline says:


The use of |-X| as a prefix to indicate "non-standard" options will be 
discontinued for new options, although command-line help may continue 
to draw a distinction between more commonly used options and those for 
advanced use.


You can consider `--management` as an alternative.  Should this be a 
launcher option that converts it to the corresponding 
`-Dcom.sun.management.jmxremote.` rather than a VM option?


Mandy
[1] http://openjdk.java.net/jeps/293

On 1/24/18 11:21 PM, Harsha Wardhana B wrote:


Hi Erik,

The minimal command line would be,

"-Xmanagement", that will start only the local management server.

"-Xmanagement:local=true,port=" will start the remote management 
server without SSL or authentication.



On Wednesday 24 January 2018 06:13 PM, Erik Gahlin wrote:

Hi Harsha,

Very nice to see progress on this!

Before reviewing, the minimal command line to start up the default 
management server now becomes


-Xmanagement:ssl=false,authenticate=false

No. Please refer above for minimal options.


and if you use a property that doesn't exist, or that is mandatory, 
you will get an error message stating what is wrong?
If we use property, that doesn't exist, we get invalid option error. 
As said before, no options are mandatory.

///
//./java 
-Xmanagement:ssl=true,authenticate=false,rmiregistry_ssl=true 
HelloWorld//

//Error: Invalid option specified: rmiregistry_ssl//
///


Could we reduce the command line further, so only a single property 
is needed:


-Xmanagement:secure=false

or perhaps:

-Xmanagement:unsecure

which would set ssl=false,authenticate=false, because that is what 
you want 99% of the time.


Thanks
Erik


Thanks
Harsha

Hi,

Please review the changes for above enhancement having webrev at,

http://cr.openjdk.java.net/~hb/8187498/webrev.00/

Thanks
Harsha










Re: RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-01-24 Thread Harsha Wardhana B

Hi Erik,

The minimal command line would be,

"-Xmanagement", that will start only the local management server.

"-Xmanagement:local=true,port=" will start the remote management 
server without SSL or authentication.



On Wednesday 24 January 2018 06:13 PM, Erik Gahlin wrote:

Hi Harsha,

Very nice to see progress on this!

Before reviewing, the minimal command line to start up the default 
management server now becomes


-Xmanagement:ssl=false,authenticate=false

No. Please refer above for minimal options.


and if you use a property that doesn't exist, or that is mandatory, 
you will get an error message stating what is wrong?
If we use property, that doesn't exist, we get invalid option error. As 
said before, no options are mandatory.

///
//./java -Xmanagement:ssl=true,authenticate=false,rmiregistry_ssl=true 
HelloWorld//

//Error: Invalid option specified: rmiregistry_ssl//
///


Could we reduce the command line further, so only a single property is 
needed:


-Xmanagement:secure=false

or perhaps:

-Xmanagement:unsecure

which would set ssl=false,authenticate=false, because that is what you 
want 99% of the time.


Thanks
Erik


Thanks
Harsha

Hi,

Please review the changes for above enhancement having webrev at,

http://cr.openjdk.java.net/~hb/8187498/webrev.00/

Thanks
Harsha






RFR: JDK-8187498: Add a -Xmanagement flag as syntactic sugar for -Dcom.sun.management.jmxremote.* properties

2018-01-24 Thread Harsha Wardhana B

Hi,

Please review the changes for above enhancement having webrev at,

http://cr.openjdk.java.net/~hb/8187498/webrev.00/

Thanks
Harsha


Re: RFR : JDK-8175542 - JMX: Not enough JDP packets received

2018-01-11 Thread Harsha Wardhana B

Hi Amit,

Looks okay to me.

Thanks

Harsha


On Wednesday 03 January 2018 05:54 PM, Amit Sapre wrote:


Thanks Harsha for the inputs.

I made changes in this webrev : 
http://cr.openjdk.java.net/~asapre/webrev/2018/JDK-8175542/webrev.01/ 
<http://cr.openjdk.java.net/%7Easapre/webrev/2018/JDK-8175542/webrev.01/>


Thanks,

Amit

*From:*Harsha Wardhana B
*Sent:* Wednesday, December 13, 2017 5:32 PM
*To:* serviceability-dev@openjdk.java.net
*Subject:* Re: RFR : JDK-8175542 - JMX: Not enough JDP packets received

Hi Amit,

Increasing the timeout 'TIME_OUT_FACTOR' will increase both socket and 
test-case timeout. The test passed as can be seen from the log, but 
because of the race-condition: hasTestLivedLongEnough() checked before 
shouldContinue(), the test was declared failed because of time-out.


One possible fix would be to change line 80 to,

        if (shouldContinue() && hasTestLivedLongEnough())

Thanks

Harsha

On Wednesday 13 December 2017 11:03 AM, Amit Sapre wrote:

Hello,

Please review the timeout fix for this bug.

Bug ID : https://bugs.openjdk.java.net/browse/JDK-8175542

Webrev :
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-8175542/webrev.00/
<http://cr.openjdk.java.net/%7Easapre/webrev/2017/JDK-8175542/webrev.00/>

Thanks,

Amit





Re: RFR : JDK-8175542 - JMX: Not enough JDP packets received

2017-12-13 Thread Harsha Wardhana B

Hi Amit,

Increasing the timeout 'TIME_OUT_FACTOR' will increase both socket and 
test-case timeout. The test passed as can be seen from the log, but 
because of the race-condition: hasTestLivedLongEnough() checked before 
shouldContinue(), the test was declared failed because of time-out.


One possible fix would be to change line 80 to,

        if (shouldContinue() && hasTestLivedLongEnough())

Thanks

Harsha


On Wednesday 13 December 2017 11:03 AM, Amit Sapre wrote:


Hello,

Please review the timeout fix for this bug.

Bug ID : https://bugs.openjdk.java.net/browse/JDK-8175542

Webrev : 
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-8175542/webrev.00/ 



Thanks,

Amit





Re: [TestBug] RFR : JDK-8192909 - Invalid username or password in HashedPasswordFileTest.java

2017-12-05 Thread Harsha Wardhana B

Thanks Daniel and Christoph for review.

-Harsha

On Tuesday 05 December 2017 08:11 PM, Daniel Fuchs wrote:

+1

-- daniel

On 05/12/2017 12:04, Harsha Wardhana B wrote:

Hi Daniel,


On Tuesday 05 December 2017 03:42 PM, Daniel Fuchs wrote:

Hi Harsha,

Looks good.

Thanks for the review.


nit:

 366 if(random.nextBoolean()) {
 367 String[] tokens = line.split("\\s+");
 368 if ((tokens.length == 4 || tokens.length == 
3)) {


inverting the two if () (testing for the applicability of the line
first) would probably give a better chance that an existing
password is replaced, unless most lines are applicable.
All the lines will be applicable. The password file will be hashed 
before the above lines are executed. An Assert statement at line 353 
makes sure of that. Hence no point inverting the two if().


best regards,

-- daniel

Regards
Harsha


n 04/12/2017 18:27, Harsha Wardhana B wrote:

Hi All,

Please review and provide comments for fix for,

issue: https://bugs.openjdk.java.net/browse/JDK-8192909

having webrev at,

webrev : http://cr.openjdk.java.net/~hb/8192909/webrev.00/

Fix details: The test was failing intermittently because of 
duplicate entries for role in input password file. The duplicate 
entries get over-written by JMX agent, but the client was testing 
with stale entries for duplicated role. Also, the test now uses a 
single random number generator from test package 
(Utils.getRandomInstance) instead of two.


Regards

Harsha











Re: [TestBug] RFR : JDK-8192909 - Invalid username or password in HashedPasswordFileTest.java

2017-12-05 Thread Harsha Wardhana B

Hi Daniel,


On Tuesday 05 December 2017 03:42 PM, Daniel Fuchs wrote:

Hi Harsha,

Looks good.

Thanks for the review.


nit:

 366 if(random.nextBoolean()) {
 367 String[] tokens = line.split("\\s+");
 368 if ((tokens.length == 4 || tokens.length == 
3)) {


inverting the two if () (testing for the applicability of the line
first) would probably give a better chance that an existing
password is replaced, unless most lines are applicable.
All the lines will be applicable. The password file will be hashed 
before the above lines are executed. An Assert statement at line 353 
makes sure of that. Hence no point inverting the two if().


best regards,

-- daniel

Regards
Harsha


n 04/12/2017 18:27, Harsha Wardhana B wrote:

Hi All,

Please review and provide comments for fix for,

issue: https://bugs.openjdk.java.net/browse/JDK-8192909

having webrev at,

webrev : http://cr.openjdk.java.net/~hb/8192909/webrev.00/

Fix details: The test was failing intermittently because of duplicate 
entries for role in input password file. The duplicate entries get 
over-written by JMX agent, but the client was testing with stale 
entries for duplicated role. Also, the test now uses a single random 
number generator from test package (Utils.getRandomInstance) instead 
of two.


Regards

Harsha







Re: [TestBug] RFR : JDK-8192909 - Invalid username or password in HashedPasswordFileTest.java

2017-12-04 Thread Harsha Wardhana B

Thanks Christoph for the review.

Can I get one more review please?

-Harsha

On Tuesday 05 December 2017 11:29 AM, Langer, Christoph wrote:

Hi Harsha,

this looks good to me.

Small finding: Line 366, there could be a space between if and (.

Best regards
Christoph


-Original Message-
From: serviceability-dev [mailto:serviceability-dev-
boun...@openjdk.java.net] On Behalf Of Harsha Wardhana B
Sent: Montag, 4. Dezember 2017 19:28
To: serviceability-dev@openjdk.java.net
Subject: [TestBug] RFR : JDK-8192909 - Invalid username or password in
HashedPasswordFileTest.java

Hi All,

Please review and provide comments for fix for,

issue: https://bugs.openjdk.java.net/browse/JDK-8192909

having webrev at,

webrev : http://cr.openjdk.java.net/~hb/8192909/webrev.00/

Fix details: The test was failing intermittently because of duplicate
entries for role in input password file. The duplicate entries get
over-written by JMX agent, but the client was testing with stale entries
for duplicated role. Also, the test now uses a single random number
generator from test package (Utils.getRandomInstance) instead of two.

Regards

Harsha




[TestBug] RFR : JDK-8192909 - Invalid username or password in HashedPasswordFileTest.java

2017-12-04 Thread Harsha Wardhana B

Hi All,

Please review and provide comments for fix for,

issue: https://bugs.openjdk.java.net/browse/JDK-8192909

having webrev at,

webrev : http://cr.openjdk.java.net/~hb/8192909/webrev.00/

Fix details: The test was failing intermittently because of duplicate 
entries for role in input password file. The duplicate entries get 
over-written by JMX agent, but the client was testing with stale entries 
for duplicated role. Also, the test now uses a single random number 
generator from test package (Utils.getRandomInstance) instead of two.


Regards

Harsha



Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-11-12 Thread Harsha Wardhana B

Hi Daniel,

Maintaining a warning or info log requires internationalization and 
since java.management module does not have the necessary resource 
bundles, it becomes complicated to take up that activity as a part of 
this enhancement.  Hence I have changed all the logs to debug. We can 
take up changing logging level and internationalization as a separate 
issue. I have updated the webrev in-place. Please review and let me know 
if you are okay with it.


Thanks
Harsha

On Friday 10 November 2017 07:50 PM, Daniel Fuchs wrote:

Hi Harsha,

On 10/11/2017 12:38, Harsha Wardhana B wrote:

Hi,

Please find the below webrev with the following changes.

1. All the reads/writes into the password file are synchronized w.r.t 
threads within the JVM and across multiple JVM processes. It is 
possible that some edits made to file while the agent is running 
might be lost and hence added a cautionary note in 
jmxremote.password.template.


OK - given the complexity of the alternative I believe what you
have now should be considered "good enough". We can always revisit
later if it proves to cause issues. Thanks for adding the note
to the jmxremote.password.template.

2. Added a new test-case 'testMultipleClients' that validates 
concurrent read/writes


Thanks for doing that!



3. Added an info log when the password file is over-written.

http://cr.openjdk.java.net/~hb/5016517/webrev.08/

Please review the latest webrev.


HashPasswordManager:

 204 } catch (NoSuchAlgorithmException ex) {
 205 if (logger.warningOn()) {
 206 logger.warning("authenticate", "Unrecognized 
hash algorithm : "
 207 + 
userCredentialsMap.get(userName).hashAlgorithm

 208 + " - for user : " + userName);
 209 }
 210 return false;
 211 }
 212 } else {
 213 if (logger.warningOn()) {
 214 logger.warning("authenticate", "Unknown user : " 
+ userName);

 215 }
 216 return false;
 217 }

and elsewhere in this file: these should not be warnings: debug at
the most.

 318 if (logger.infoOn()) {
 319 logger.info("loadPasswords",
 320 "Wrote hashed passwords to file : " + 
passwordFile);

 321 }

I think this should be debug as well.


The last one might probably stay as a warning but if so:

   1. it should be printed only once (and not for every
  new client that comes)
   2. It might need to be internationalized.

 322 } else if (logger.warningOn()) {
 323 logger.warning("loadPasswords",
 324 "Passwords in " + passwordFile + " are in 
clear and password file is read-only. "
 325 + "Passwords cannot be hashed 
");

 326 }

The rest looks good to me!

best regards,

-- daniel



Thanks
Harsha

On Wednesday 08 November 2017 09:29 AM, mandy chung wrote:



On 11/7/17 9:04 AM, Harsha Wardhana B wrote:


Hi Mandy,

To summarize the changes,

1. The header will not contain the file modification timestamp. 
Instead when the password file is modified, a debug log will be 
printed. The log will contain the timestamp.


2. The password file is now protected from concurrent writes from 
within the JVM.


3. HashedPasswordManager.authenticate accepts char[] for password 
instead of String.




Thanks for this. That helps.
Header will be inserted. Apart from that all the comments will be 
retained.


I think this header can also be taken out.  The comment may already 
be copied from the template or deleted on purpose.


Also log a message when the file is overridden - we didn't discuss 
the format but I think it should include the pathname of the file 
and the role name of the overridden entries (should it be info 
level?). line 308-311 is debug message - is that the one?
I guess this wasn't discussed. We just output a debug log saying 
the file is overwritten. File name can be mentioned in the log.


INFO log message seems more appropriate.

Mandy








Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-11-10 Thread Harsha Wardhana B

Hi,

Please find the below webrev with the following changes.

1. All the reads/writes into the password file are synchronized w.r.t 
threads within the JVM and across multiple JVM processes. It is possible 
that some edits made to file while the agent is running might be lost 
and hence added a cautionary note in jmxremote.password.template.


2. Added a new test-case 'testMultipleClients' that validates concurrent 
read/writes


3. Added an info log when the password file is over-written.

http://cr.openjdk.java.net/~hb/5016517/webrev.08/

Please review the latest webrev.

Thanks
Harsha

On Wednesday 08 November 2017 09:29 AM, mandy chung wrote:



On 11/7/17 9:04 AM, Harsha Wardhana B wrote:


Hi Mandy,

To summarize the changes,

1. The header will not contain the file modification timestamp. 
Instead when the password file is modified, a debug log will be 
printed. The log will contain the timestamp.


2. The password file is now protected from concurrent writes from 
within the JVM.


3. HashedPasswordManager.authenticate accepts char[] for password 
instead of String.




Thanks for this. That helps.
Header will be inserted. Apart from that all the comments will be 
retained.


I think this header can also be taken out.  The comment may already be 
copied from the template or deleted on purpose.


Also log a message when the file is overridden - we didn't discuss 
the format but I think it should include the pathname of the file 
and the role name of the overridden entries (should it be info 
level?).  line 308-311 is debug message - is that the one?
I guess this wasn't discussed. We just output a debug log saying the 
file is overwritten. File name can be mentioned in the log.


INFO log message seems more appropriate.

Mandy




Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-11-08 Thread Harsha Wardhana B

Hi Daniel,


On Tuesday 07 November 2017 10:43 PM, Daniel Fuchs wrote:

Hi Harsha,

HashedPasswordManager.java:

I'd suggest to use java.nio.charset.StandardCharset.UTF_8 instead of
Charset.forName("UTF-8");

ok.


The reading of the password file should probably not be allowed if
some process (this one or another one) is currently writing to it,
because you could just read some garbage.
I think reading a file while it is being written to might give us 
incomplete data (depending on how often we flush the stream) but not 
garbage.


Maybe you'd need a ReadWriteLock here or something to avoid
having this become a bottleneck - but then it probably means
you'll need to keep track of which file is protected by
a FileLock too.
I think using a local lock (synchronized block or r/w lock) in 
conjunction with FileLock for both read/write operations should solve 
this problem. I am not sure why we need to keep track of FileLocks. I 
will send a modified webrev.


Also previously it was possible to update the
password file while the agent was running, as the file was
read with each login().
I'm suspecting your change will break this partly as it
looks as if reloading the file does not clear the
new userCredentialsMap.
Now also the file gets reloaded for each login. Not clearing the 
userCredentialMap might leave stale entries (which should be cleared), 
but new entries will get updated and hence it will not break existing 
functionality. The test-cases validate the above use-case.


best regards,

-- daniel



-Harsha

On 07/11/2017 16:26, Harsha Wardhana B wrote:

Hi,

Please find below the webrev addressing Daniel and Mandy's comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.07/

-Harsha

On Wednesday 01 November 2017 09:42 PM, Daniel Fuchs wrote:

On 31/10/2017 17:07, mandy chung wrote:

On 10/31/17 8:55 AM, Harsha Wardhana B wrote:


Hi Mandy,

Below is the new webrev incorporating below review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.06/


Looks okay in general except this:

  286 // Check if header needs to be inserted
  287 if (sbuf.indexOf("# The passwords in this file are 
hashed") != 0) {

  288 String lastUpdated = "# file last updated on - "
  289 + new SimpleDateFormat("MM/dd/ 
HH:mm:ss").format(new Date()) + "\n\n";

  290 sbuf.insert(0, header + lastUpdated);
  291 }

Relying on matching the partial header string is fragile.
Also the timestamp is not updated if the file contains such
heading but the file is re-written again.

You should probably drop the header (auto-inserted), not add
it to sbuf, and always add the header when updating the
password file.


Sorry Mandy, that was my demand. The header is several lines long.
It will look strange if it's added several times to the password file
every time the user/administrator adds/changes a password.

Concerning FileLock - I'm not an expert there, but the Javadoc says:

https://docs.oracle.com/javase/9/docs/api/java/nio/channels/FileLock.html 


"File locks are held on behalf of the entire Java virtual machine.
 They are not suitable for controlling access to a file by multiple
 threads within the same virtual machine."

Which means you need to also protect against concurrent writes to
the same file from within the same JVM by some other means.

Also I wonder if HashedPasswordManager.authenticate should take
a char[] array rather than a String for the password.

best regards,

-- daniel





Mandy











Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-11-07 Thread Harsha Wardhana B

Hi Mandy,

To summarize the changes,

1. The header will not contain the file modification timestamp. Instead 
when the password file is modified, a debug log will be printed. The log 
will contain the timestamp.


2. The password file is now protected from concurrent writes from within 
the JVM.


3. HashedPasswordManager.authenticate accepts char[] for password 
instead of String.


-Harsha

On Tuesday 07 November 2017 10:24 PM, mandy chung wrote:



On 11/7/17 8:26 AM, Harsha Wardhana B wrote:

Hi,

Please find below the webrev addressing Daniel and Mandy's comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.07/


Can you summarize the change?

I thought we agree to only replace the clear passwords with the hashes 
and not to alter any other content nor inserting any header.

Header will be inserted. Apart from that all the comments will be retained.
Also log a message when the file is overridden - we didn't discuss the 
format but I think it should include the pathname of the file and the 
role name of the overridden entries (should it be info level?).  line 
308-311 is debug message - is that the one?
I guess this wasn't discussed. We just output a debug log saying the 
file is overwritten. File name can be mentioned in the log.


Mandy

Harsha


Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-11-07 Thread Harsha Wardhana B

Hi,

Please find below the webrev addressing Daniel and Mandy's comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.07/

-Harsha

On Wednesday 01 November 2017 09:42 PM, Daniel Fuchs wrote:

On 31/10/2017 17:07, mandy chung wrote:

On 10/31/17 8:55 AM, Harsha Wardhana B wrote:


Hi Mandy,

Below is the new webrev incorporating below review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.06/


Looks okay in general except this:

  286 // Check if header needs to be inserted
  287 if (sbuf.indexOf("# The passwords in this file are 
hashed") != 0) {

  288 String lastUpdated = "# file last updated on - "
  289 + new SimpleDateFormat("MM/dd/ 
HH:mm:ss").format(new Date()) + "\n\n";

  290 sbuf.insert(0, header + lastUpdated);
  291 }

Relying on matching the partial header string is fragile.
Also the timestamp is not updated if the file contains such
heading but the file is re-written again.

You should probably drop the header (auto-inserted), not add
it to sbuf, and always add the header when updating the
password file.


Sorry Mandy, that was my demand. The header is several lines long.
It will look strange if it's added several times to the password file
every time the user/administrator adds/changes a password.

Concerning FileLock - I'm not an expert there, but the Javadoc says:

https://docs.oracle.com/javase/9/docs/api/java/nio/channels/FileLock.html
"File locks are held on behalf of the entire Java virtual machine.
 They are not suitable for controlling access to a file by multiple
 threads within the same virtual machine."

Which means you need to also protect against concurrent writes to
the same file from within the same JVM by some other means.

Also I wonder if HashedPasswordManager.authenticate should take
a char[] array rather than a String for the password.

best regards,

-- daniel





Mandy







Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-31 Thread Harsha Wardhana B

Hi Mandy,

Below is the new webrev incorporating below review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.06/


On Monday 30 October 2017 11:34 PM, mandy chung wrote:

http://cr.openjdk.java.net/~hb/5016517/webrev.05/


Looks okay in general.   Daniel is closer to the FileLoginModule 
implementation that I will count on his review.


FileLoginModule.java

225 if(hashPwdMgr == null) {
226 hashPwdMgr = new HashedPasswordManager(passwordFile, hashPasswords);
227 } else { 228 hashPwdMgr.loadPasswords(); 229 } Will hashPwdMgr be 
initialized multiple threads concurrently? Does this need to be 
synchronized?
Without synchronization, it would leave an orphan instance of 
HashedPasswordManager. Fixed it.
243 ace.setStackTrace(e.getStackTrace()); I think ace.initCause(e) 
instead of replacing the stack trace would help debugging. ACE should 
have been rev'ed to take the cause parameter (a separate issue).  
jmxremote.password.template 49 # 
https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest


Please refer to JDK 9 docs.
255 "jmx.remote.x.password.tohashes";
305 # com.sun.management.jmxremote.password.tohashes = true|falseSince 
"to hashes" are two words, capitalize "H" is a recommended convention.

HashedPasswordManager.java

  214 Stream lines = Files.lines(Paths.get(passwordFile));

This should be called with try-with-resource.

Done.


It would be useful to record the timestamp of when the password
file is updated with the hashed passwords.

Added it as a part of the header. The header now looks like below.

# The passwords in this file are hashed.
# In order to change password for a role, replace hashed password entry
# with clear text password or new hashed password. If new password is in 
clear,

# it will be replaced with its hash when new login attempt is made.

# file last updated on - 10/31/2017 21:23:52

-Harsha


Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-26 Thread Harsha Wardhana B

Sorry. Missed the webrev -

http://cr.openjdk.java.net/~hb/5016517/webrev.05/


On Friday 27 October 2017 09:27 AM, Harsha Wardhana B wrote:


Hi,

Below is the updated webrev incorporating review comments from Daniel, 
Roger and Mandy. The password file will now be locked before writing.


Mandy,

49 # 
https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest

50 # MD5, SHA-1 and SHA-256 are supported algorithms.
51 # This is an optional field. If not specified SHA-256 will be 
assumed.

I would avoid the link to the documentation of a specific JDK release.
Maybe say:

Refer to "Java Security Standard Algorithm Names Specification"
for supported algorithm.
Link to the documentation is required because the exact strings as 
specified in the documentation must be specified. "Java Security 
Standard Algorithm Names Specification" does not actually help. So I 
have not removed the link to the documentation.


-Harsha


On Thursday 12 October 2017 09:22 PM, Harsha Wardhana B wrote:


Sure. I will send out a modified webrev soon.

-Harsha


On Thursday 12 October 2017 08:52 PM, mandy chung wrote:



On 10/12/17 8:18 AM, Harsha Wardhana B wrote:




On Thursday 12 October 2017 08:40 PM, mandy chung wrote:



On 10/12/17 1:16 AM, Harsha Wardhana B wrote:


I'm thinking any better alternative to the new property name?? 
com.sun.management.jmxremote.password.hashes 
com.sun.management.jmxremote.password.asHashes com.sun.management.jmxremote.passowrd.toHashes


I suggest to rename 
com.sun.management.jmxremote.password.hashpasswords to 
com.sun.management.jmxremote.password.hashes.


What do you think?
We want the property to suggest an action and hence *.toHashes 
would be better than *.hashes. 


"toHashes" suffix is also good to me.


67 # If multiple entries are found for the same role name, then 
the last one 68 # is used.
If there are multiple entries of the same role, will all entries 
be overridden with hash value? It may be better to detect as an 
error when there are more than one entries of the same role?
It would be better to log a warning. Throwing an error would seem 
a bit extreme.


What happen to the duplicated entries?  The clear password will 
stay?  Warning is fine.
The duplicated entries will be removed. The last entry for a given 
role along with its hashed password will be written into the file.




The other alternative is to override it with its hash value and 
output a warning that this entry is ignored.   This will leave it 
for the user to remove the entries.


Mandy









Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-26 Thread Harsha Wardhana B

Hi,

Below is the updated webrev incorporating review comments from Daniel, 
Roger and Mandy. The password file will now be locked before writing.


Mandy,

49 # 
https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest

50 # MD5, SHA-1 and SHA-256 are supported algorithms.
51 # This is an optional field. If not specified SHA-256 will be assumed.
I would avoid the link to the documentation of a specific JDK release.
Maybe say:

Refer to "Java Security Standard Algorithm Names Specification"
for supported algorithm.
Link to the documentation is required because the exact strings as 
specified in the documentation must be specified. "Java Security 
Standard Algorithm Names Specification" does not actually help. So I 
have not removed the link to the documentation.


-Harsha


On Thursday 12 October 2017 09:22 PM, Harsha Wardhana B wrote:


Sure. I will send out a modified webrev soon.

-Harsha


On Thursday 12 October 2017 08:52 PM, mandy chung wrote:



On 10/12/17 8:18 AM, Harsha Wardhana B wrote:




On Thursday 12 October 2017 08:40 PM, mandy chung wrote:



On 10/12/17 1:16 AM, Harsha Wardhana B wrote:


I'm thinking any better alternative to the new property name?? 
com.sun.management.jmxremote.password.hashes 
com.sun.management.jmxremote.password.asHashes com.sun.management.jmxremote.passowrd.toHashes


I suggest to rename 
com.sun.management.jmxremote.password.hashpasswords to 
com.sun.management.jmxremote.password.hashes.


What do you think?
We want the property to suggest an action and hence *.toHashes would 
be better than *.hashes. 


"toHashes" suffix is also good to me.


67 # If multiple entries are found for the same role name, then 
the last one 68 # is used.
If there are multiple entries of the same role, will all entries 
be overridden with hash value? It may be better to detect as an 
error when there are more than one entries of the same role?
It would be better to log a warning. Throwing an error would seem 
a bit extreme.


What happen to the duplicated entries?  The clear password will 
stay?  Warning is fine.
The duplicated entries will be removed. The last entry for a given 
role along with its hashed password will be written into the file.




The other alternative is to override it with its hash value and 
output a warning that this entry is ignored.   This will leave it for 
the user to remove the entries.


Mandy







Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-12 Thread Harsha Wardhana B

Sure. I will send out a modified webrev soon.

-Harsha


On Thursday 12 October 2017 08:52 PM, mandy chung wrote:



On 10/12/17 8:18 AM, Harsha Wardhana B wrote:




On Thursday 12 October 2017 08:40 PM, mandy chung wrote:



On 10/12/17 1:16 AM, Harsha Wardhana B wrote:


I'm thinking any better alternative to the new property name?? 
com.sun.management.jmxremote.password.hashes 
com.sun.management.jmxremote.password.asHashes com.sun.management.jmxremote.passowrd.toHashes


I suggest to rename 
com.sun.management.jmxremote.password.hashpasswords to 
com.sun.management.jmxremote.password.hashes.


What do you think?
We want the property to suggest an action and hence *.toHashes would 
be better than *.hashes. 


"toHashes" suffix is also good to me.


67 # If multiple entries are found for the same role name, then 
the last one 68 # is used.
If there are multiple entries of the same role, will all entries 
be overridden with hash value? It may be better to detect as an 
error when there are more than one entries of the same role?
It would be better to log a warning. Throwing an error would seem a 
bit extreme.


What happen to the duplicated entries?  The clear password will 
stay?  Warning is fine.
The duplicated entries will be removed. The last entry for a given 
role along with its hashed password will be written into the file.




The other alternative is to override it with its hash value and output 
a warning that this entry is ignored.   This will leave it for the 
user to remove the entries.


Mandy





Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-12 Thread Harsha Wardhana B



On Thursday 12 October 2017 08:40 PM, mandy chung wrote:



On 10/12/17 1:16 AM, Harsha Wardhana B wrote:


I'm thinking any better alternative to the new property name?? 
com.sun.management.jmxremote.password.hashes 
com.sun.management.jmxremote.password.asHashes com.sun.management.jmxremote.passowrd.toHashes


I suggest to rename 
com.sun.management.jmxremote.password.hashpasswords to 
com.sun.management.jmxremote.password.hashes.


What do you think?
We want the property to suggest an action and hence *.toHashes would be 
better than *.hashes.


67 # If multiple entries are found for the same role name, then the 
last one 68 # is used.
If there are multiple entries of the same role, will all entries be 
overridden with hash value? It may be better to detect as an error 
when there are more than one entries of the same role?
It would be better to log a warning. Throwing an error would seem a 
bit extreme.


What happen to the duplicated entries?  The clear password will stay?  
Warning is fine.
The duplicated entries will be removed. The last entry for a given role 
along with its hashed password will be written into the file.


Mandy


Harsha


Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-12 Thread Harsha Wardhana B

Hi Roger,


On Wednesday 11 October 2017 09:21 PM, Roger Riggs wrote:

Hi Harsha,

conf/management.properties: - typo line 307: pa*sss*words


HashedPasswordManager.java:
 - line 46: "classes" -> "class"

- line 84-87 "private" and 'static" come before "final" in declarations.

 - 158 and everywhere: add space after "if"  before "("

 - line 202: add "the" before password file.


Done.
 - line 287:  why a separate canWriteToFile(); it does the same check 
as newFileWriter(passwordFile);

   instead catch the exception and log then ignore.

It will be replaced by nio APIs.

Thanks
Harsha


Looking good

Regards, Roger

On 10/11/2017 5:00 AM, Daniel Fuchs wrote:

Hi Harsha,

Your changes look good. However I have still a nagging doubt:

What happens if two Java process share the same password file,
and it needs hashing? Are there any protection in place
to prevent the two processes from writing to the same
file concurrently?

best regards,

-- daniel

On 09/10/2017 06:34, Harsha Wardhana B wrote:

Hi Daniel,

Below is the webrev addressing the review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.04/

On Friday 06 October 2017 03:38 PM, Daniel Fuchs wrote:

Hi Harsha,

Good work!

> http://cr.openjdk.java.net/~hb/5016517/webrev.03/

long standing typo in management.properties at line 90:

  measureRole => monitorRole

Done.


HashedPasswordManager.java: loadPasswords()

It seems this function will add the header to the file even
if it already contains the header.

So every time a user/administrator wants to change/add a password,
the header will be inserted again.


Yes. It is fixed in the new webrev.


HashedPasswordFileTest should probably have a test for this
scenario as well:

generate password file with clear text password
load it, then verify passwords have been hashed (properly)
add some new user/name password to the same file
load it again, verify all passwords are hashed
(do this a number of times - to make sure it doesn't
 break the second or third time)
and finally verify the header is only present once ;-)


Done. Added a testcase for the same.

I'm surprised no other tests had to be modified.
Is password hash disabled by default in the default agent?

Password hashing is enabled by default. But it is only the 
implementation that is changed. The pluggable JAAS mechanism 
isolates interfaces from implementation. So in theory, all tests 
should pass.

If not then you should try (locally) running jtreg
more than once over the default agent tests.
Just make sure running the same test twice doesn't
make the legacy tests that use password files failing the
second time when they discover that passwords have been
hashed under their feet (the client part of the test
might be reading the password file too to see which
password it should send to the agent).

Otherwise I think it looks good to me - provided all
tests are passing!


Done. Had a few test failures but nothing related to this enhancement.

best regards,

-- daniel

Thanks
Harsha


On 06/10/2017 06:25, Harsha Wardhana B wrote:

Hi All,

Previously, for default agent, hashing of the passwords was done 
during the agent boot-up (ConnectorBootstrap.java). That was an 
error since login configuration could be different and is 
determined only when a login attempt is made. It would be then 
pointless to hash the password file. The fix for above and some 
off-list comments are incorporated in webrev below.


http://cr.openjdk.java.net/~hb/5016517/webrev.03/

-Harsha


On Wednesday 04 October 2017 01:53 PM, Harsha Wardhana B wrote:

Hi Roger,

Below is the webrev incorporating changes suggested by you.

http://cr.openjdk.java.net/~hb/5016517/webrev.02/

-Harsha

On Wednesday 04 October 2017 12:54 AM, Roger Riggs wrote:

Hi Harsha,

FileLoginModule.java:  104:  Add a period at the end of the the 
sentence.


JMXPluggableAuthenticator.java: line 306:  Is the difference 
between singular and plural significant?

  It would be less confusing if both were plural (hashPasswords).

Ok.

ConnectorBootstrap:
134: ...password.file.hash" and HashedPasswordManager disagree 
on the exact string.
I would propose 'hashpasswords' as the suffix in all places to 
be consistent
in ConnectorBootstrap.java, HashedPasswordManager (except for 
capitalization),

jmxremote.password.template, and management.properties

Do you want to rename HashedPasswordManager class?


As is you have a mix of "...password.hash", 
"...password.file.hash", "...hashpassword";

that's not good for knowing there is only one semantic.

line 482:  " ," -> ", "  space after comma, not before


Will incorporate above comments.
line: 771: is it intentional to discard the reference to the new 
HashedPasswordManager?
If the intention is only to use the side effect of 
loadPasswords, then please

create a static method in HashedPasswordManage

Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-12 Thread Harsha Wardhana B

Hi Daniel,

The contents written into the password file are identical and written at 
the same offset. Hence the order of the writes should not matter. 
However there is a possibility that file could be read in the midst of 
password change and different file contents could be read by different 
processes. Since multiple writes could be done on the file, it is 
possible for differing contents to be interleaved into the file, thereby 
corrupting the entire file.


I will add FileLock from the nio package to avoid the above race condition.

Thanks

Harsha




On Wednesday 11 October 2017 02:30 PM, Daniel Fuchs wrote:

Hi Harsha,

Your changes look good. However I have still a nagging doubt:

What happens if two Java process share the same password file,
and it needs hashing? Are there any protection in place
to prevent the two processes from writing to the same
file concurrently?

best regards,

-- daniel

On 09/10/2017 06:34, Harsha Wardhana B wrote:

Hi Daniel,

Below is the webrev addressing the review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.04/

On Friday 06 October 2017 03:38 PM, Daniel Fuchs wrote:

Hi Harsha,

Good work!

> http://cr.openjdk.java.net/~hb/5016517/webrev.03/

long standing typo in management.properties at line 90:

  measureRole => monitorRole

Done.


HashedPasswordManager.java: loadPasswords()

It seems this function will add the header to the file even
if it already contains the header.

So every time a user/administrator wants to change/add a password,
the header will be inserted again.


Yes. It is fixed in the new webrev.


HashedPasswordFileTest should probably have a test for this
scenario as well:

generate password file with clear text password
load it, then verify passwords have been hashed (properly)
add some new user/name password to the same file
load it again, verify all passwords are hashed
(do this a number of times - to make sure it doesn't
 break the second or third time)
and finally verify the header is only present once ;-)


Done. Added a testcase for the same.

I'm surprised no other tests had to be modified.
Is password hash disabled by default in the default agent?

Password hashing is enabled by default. But it is only the 
implementation that is changed. The pluggable JAAS mechanism isolates 
interfaces from implementation. So in theory, all tests should pass.

If not then you should try (locally) running jtreg
more than once over the default agent tests.
Just make sure running the same test twice doesn't
make the legacy tests that use password files failing the
second time when they discover that passwords have been
hashed under their feet (the client part of the test
might be reading the password file too to see which
password it should send to the agent).

Otherwise I think it looks good to me - provided all
tests are passing!


Done. Had a few test failures but nothing related to this enhancement.

best regards,

-- daniel

Thanks
Harsha


On 06/10/2017 06:25, Harsha Wardhana B wrote:

Hi All,

Previously, for default agent, hashing of the passwords was done 
during the agent boot-up (ConnectorBootstrap.java). That was an 
error since login configuration could be different and is 
determined only when a login attempt is made. It would be then 
pointless to hash the password file. The fix for above and some 
off-list comments are incorporated in webrev below.


http://cr.openjdk.java.net/~hb/5016517/webrev.03/

-Harsha


On Wednesday 04 October 2017 01:53 PM, Harsha Wardhana B wrote:

Hi Roger,

Below is the webrev incorporating changes suggested by you.

http://cr.openjdk.java.net/~hb/5016517/webrev.02/

-Harsha

On Wednesday 04 October 2017 12:54 AM, Roger Riggs wrote:

Hi Harsha,

FileLoginModule.java:  104:  Add a period at the end of the the 
sentence.


JMXPluggableAuthenticator.java: line 306:  Is the difference 
between singular and plural significant?

  It would be less confusing if both were plural (hashPasswords).

Ok.

ConnectorBootstrap:
134: ...password.file.hash" and HashedPasswordManager disagree on 
the exact string.
I would propose 'hashpasswords' as the suffix in all places to be 
consistent
in ConnectorBootstrap.java, HashedPasswordManager (except for 
capitalization),

jmxremote.password.template, and management.properties

Do you want to rename HashedPasswordManager class?


As is you have a mix of "...password.hash", 
"...password.file.hash", "...hashpassword";

that's not good for knowing there is only one semantic.

line 482:  " ," -> ", "  space after comma, not before


Will incorporate above comments.
line: 771: is it intentional to discard the reference to the new 
HashedPasswordManager?
If the intention is only to use the side effect of loadPasswords, 
then please

create a static method in HashedPasswordManager for that purpose.
(Even if just does the same code; it would be clear that's the 
purpose).
(It probably also implies t

Re: RFR : JDK-8044122 MBean access to the PID

2017-10-10 Thread Harsha Wardhana B

Hi Ujwal,

Could you please add a test-case to validate your changes? You can spawn 
a new process and it can exchange its pid to its parent via 
System.out/in or via sockets.


Also, VMManagementImpl:145, the change from getProcessId to getVmPid 
seems unnecessary.


-Harsha


On Tuesday 10 October 2017 05:17 PM, Ujwal Vangapally wrote:

Kindly review the changes made.

https://bugs.openjdk.java.net/browse/JDK-8044122

webrev : 
http://cr.openjdk.java.net/~uvangapally/webrev/2017/8044122/webrev.00/


CSR : https://bugs.openjdk.java.net/browse/JDK-8189091

Thanks,

Ujwal.





Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-08 Thread Harsha Wardhana B

Hi Daniel,

Below is the webrev addressing the review comments.

http://cr.openjdk.java.net/~hb/5016517/webrev.04/

On Friday 06 October 2017 03:38 PM, Daniel Fuchs wrote:

Hi Harsha,

Good work!

> http://cr.openjdk.java.net/~hb/5016517/webrev.03/

long standing typo in management.properties at line 90:

  measureRole => monitorRole

Done.


HashedPasswordManager.java: loadPasswords()

It seems this function will add the header to the file even
if it already contains the header.

So every time a user/administrator wants to change/add a password,
the header will be inserted again.


Yes. It is fixed in the new webrev.


HashedPasswordFileTest should probably have a test for this
scenario as well:

generate password file with clear text password
load it, then verify passwords have been hashed (properly)
add some new user/name password to the same file
load it again, verify all passwords are hashed
(do this a number of times - to make sure it doesn't
 break the second or third time)
and finally verify the header is only present once ;-)


Done. Added a testcase for the same.

I'm surprised no other tests had to be modified.
Is password hash disabled by default in the default agent?

Password hashing is enabled by default. But it is only the 
implementation that is changed. The pluggable JAAS mechanism isolates 
interfaces from implementation. So in theory, all tests should pass.

If not then you should try (locally) running jtreg
more than once over the default agent tests.
Just make sure running the same test twice doesn't
make the legacy tests that use password files failing the
second time when they discover that passwords have been
hashed under their feet (the client part of the test
might be reading the password file too to see which
password it should send to the agent).

Otherwise I think it looks good to me - provided all
tests are passing!


Done. Had a few test failures but nothing related to this enhancement.

best regards,

-- daniel

Thanks
Harsha


On 06/10/2017 06:25, Harsha Wardhana B wrote:

Hi All,

Previously, for default agent, hashing of the passwords was done 
during the agent boot-up (ConnectorBootstrap.java). That was an error 
since login configuration could be different and is determined only 
when a login attempt is made. It would be then pointless to hash the 
password file. The fix for above and some off-list comments are 
incorporated in webrev below.


http://cr.openjdk.java.net/~hb/5016517/webrev.03/

-Harsha


On Wednesday 04 October 2017 01:53 PM, Harsha Wardhana B wrote:

Hi Roger,

Below is the webrev incorporating changes suggested by you.

http://cr.openjdk.java.net/~hb/5016517/webrev.02/

-Harsha

On Wednesday 04 October 2017 12:54 AM, Roger Riggs wrote:

Hi Harsha,

FileLoginModule.java:  104:  Add a period at the end of the the 
sentence.


JMXPluggableAuthenticator.java: line 306:  Is the difference 
between singular and plural significant?

  It would be less confusing if both were plural (hashPasswords).

Ok.

ConnectorBootstrap:
134: ...password.file.hash" and HashedPasswordManager disagree on 
the exact string.
I would propose 'hashpasswords' as the suffix in all places to be 
consistent
in ConnectorBootstrap.java, HashedPasswordManager (except for 
capitalization),

jmxremote.password.template, and management.properties

Do you want to rename HashedPasswordManager class?


As is you have a mix of "...password.hash", 
"...password.file.hash", "...hashpassword";

that's not good for knowing there is only one semantic.

line 482:  " ," -> ", "  space after comma, not before


Will incorporate above comments.
line: 771: is it intentional to discard the reference to the new 
HashedPasswordManager?
If the intention is only to use the side effect of loadPasswords, 
then please

create a static method in HashedPasswordManager for that purpose.
(Even if just does the same code; it would be clear that's the 
purpose).
(It probably also implies that the password file will be read a 
second time somewhere else in the initialization).
Static methods just to hash passwords can be created but 
HashedPasswordManager class will have to be re-factored since almost 
all methods are using instance variables. Not sure if we want 
instance methods and look-alike static methods side-by-side. 
Wouldn't that be more confusing than current implementation?


line:770:  the string constant would be nicer as a final static 
string somewhere.

  "jmx.remote.x.password.file.hashpassword"
All of "jmx.remote.x.*" don't have static strings. They are used 'as 
is' all over the code to maintain isolation between pluggable login 
authenticator and JDK code.


Roger



Harsha


On 10/3/2017 3:47 PM, Harsha Wardhana B wrote:


Hi Roger,>>> Thanks for the detailed review. Below is the webrev 
addressing all the review comments.


http://cr.openjdk.java.net/~hb/5016517/webrev.01/

-Harsha


On Tuesday 

Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-05 Thread Harsha Wardhana B

Hi All,

Previously, for default agent, hashing of the passwords was done during 
the agent boot-up (ConnectorBootstrap.java). That was an error since 
login configuration could be different and is determined only when a 
login attempt is made. It would be then pointless to hash the password 
file. The fix for above and some off-list comments are incorporated in 
webrev below.


http://cr.openjdk.java.net/~hb/5016517/webrev.03/

-Harsha


On Wednesday 04 October 2017 01:53 PM, Harsha Wardhana B wrote:

Hi Roger,

Below is the webrev incorporating changes suggested by you.

http://cr.openjdk.java.net/~hb/5016517/webrev.02/

-Harsha

On Wednesday 04 October 2017 12:54 AM, Roger Riggs wrote:

Hi Harsha,

FileLoginModule.java:  104:  Add a period at the end of the the 
sentence.


JMXPluggableAuthenticator.java: line 306:  Is the difference between 
singular and plural significant?

  It would be less confusing if both were plural (hashPasswords).

Ok.

ConnectorBootstrap:
134: ...password.file.hash" and HashedPasswordManager disagree on the 
exact string.
I would propose 'hashpasswords' as the suffix in all places to be 
consistent
in ConnectorBootstrap.java, HashedPasswordManager (except for 
capitalization),

jmxremote.password.template, and management.properties

Do you want to rename HashedPasswordManager class?


As is you have a mix of "...password.hash", "...password.file.hash", 
"...hashpassword";

that's not good for knowing there is only one semantic.

line 482:  " ," -> ", "  space after comma, not before


Will incorporate above comments.
line: 771: is it intentional to discard the reference to the new 
HashedPasswordManager?
If the intention is only to use the side effect of loadPasswords, 
then please

create a static method in HashedPasswordManager for that purpose.
(Even if just does the same code; it would be clear that's the purpose).
(It probably also implies that the password file will be read a 
second time somewhere else in the initialization).
Static methods just to hash passwords can be created but 
HashedPasswordManager class will have to be re-factored since almost 
all methods are using instance variables. Not sure if we want instance 
methods and look-alike static methods side-by-side. Wouldn't that be 
more confusing than current implementation?


line:770:  the string constant would be nicer as a final static 
string somewhere.

  "jmx.remote.x.password.file.hashpassword"
All of "jmx.remote.x.*" don't have static strings. They are used 'as 
is' all over the code to maintain isolation between pluggable login 
authenticator and JDK code.


Roger



Harsha


On 10/3/2017 3:47 PM, Harsha Wardhana B wrote:


Hi Roger,>>>
Thanks for the detailed review. Below is the webrev addressing all 
the review comments.


http://cr.openjdk.java.net/~hb/5016517/webrev.01/

-Harsha


On Tuesday 25 April 2017 10:56 PM, Roger Riggs wrote:

Hi Harsha,

Thanks for this important improvement. Comments:


* jmxremote.password.template:
  "Passwords will be hashed by server if they are in clear." 
Perhaps should be more explicit:


   "The jmxremote.passwords file will be re-written by the server 
to replace all plain text passwords with hashed passwords when the 
file is read by the server."


line 35: "Base64 encoded hash"  -> drop the "Base64" in this line 
isn't needed and

make it seems like it should appear as 1 field instead of 2 or 3.

37+: The syntax of the file may be clearer if it includes the 
complete syntax in (line 39) not

just the password/hash fragment.

Line 41:  "W = spaces"; above "tabs" are allowed as a delimiter; it 
would be good to be consistent
and include the usualy white-space characters in the set, be as 
specific as possible.

Is this the same set of whitespace used by Regex '\\s'.
Only spaces and tabs are allowed. '\s' matches newline as well hence 
not allowed.


45: "java platform""  ->   "MD5, SDA-1, SHA-256 are supported 
algorithms."


49: be more specific about 'hashing is requested'  how? Refer to 
the management.properties

  com.sun.management.jmxremote.password.hash value.



51:  "replace hashed" -> "replace *the *hashed"
52: "with clear text or new" -> "with the clear text or the new"
52: "If new password" -> "If the new password"
53: "when new login" -> "when a new login"

60: "User generated" -> "A User generated"

67: Will the file be ignored if it has the wrong permissions. (With 
a logged message)

Addressed all the above review comments.


* management.properties

306: "(Case for true/false ignored)"  - what does this mean; I 
think it can be removed.


307: missing period at the end of the sentence.
309: "in password file" -> "in 

Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-04 Thread Harsha Wardhana B

Hi Roger,

Below is the webrev incorporating changes suggested by you.

http://cr.openjdk.java.net/~hb/5016517/webrev.02/

-Harsha

On Wednesday 04 October 2017 12:54 AM, Roger Riggs wrote:

Hi Harsha,

FileLoginModule.java:  104:  Add a period at the end of the the sentence.

JMXPluggableAuthenticator.java: line 306:  Is the difference between 
singular and plural significant?

  It would be less confusing if both were plural (hashPasswords).

Ok.

ConnectorBootstrap:
134: ...password.file.hash" and HashedPasswordManager disagree on the 
exact string.
I would propose 'hashpasswords' as the suffix in all places to be 
consistent
in ConnectorBootstrap.java, HashedPasswordManager (except for 
capitalization),

jmxremote.password.template, and management.properties

Do you want to rename HashedPasswordManager class?


As is you have a mix of "...password.hash", "...password.file.hash", 
"...hashpassword";

that's not good for knowing there is only one semantic.

line 482:  " ," -> ", "  space after comma, not before


Will incorporate above comments.
line: 771: is it intentional to discard the reference to the new 
HashedPasswordManager?
If the intention is only to use the side effect of loadPasswords, then 
please

create a static method in HashedPasswordManager for that purpose.
(Even if just does the same code; it would be clear that's the purpose).
(It probably also implies that the password file will be read a second 
time somewhere else in the initialization).
Static methods just to hash passwords can be created but 
HashedPasswordManager class will have to be re-factored since almost all 
methods are using instance variables. Not sure if we want instance 
methods and look-alike static methods side-by-side. Wouldn't that be 
more confusing than current implementation?


line:770:  the string constant would be nicer as a final static string 
somewhere.

  "jmx.remote.x.password.file.hashpassword"
All of "jmx.remote.x.*" don't have static strings. They are used 'as is' 
all over the code to maintain isolation between pluggable login 
authenticator and JDK code.


Roger



Harsha


On 10/3/2017 3:47 PM, Harsha Wardhana B wrote:


Hi Roger,

Thanks for the detailed review. Below is the webrev addressing all 
the review comments.


http://cr.openjdk.java.net/~hb/5016517/webrev.01/

-Harsha


On Tuesday 25 April 2017 10:56 PM, Roger Riggs wrote:

Hi Harsha,

Thanks for this important improvement. Comments:


* jmxremote.password.template:
  "Passwords will be hashed by server if they are in clear." Perhaps 
should be more explicit:


   "The jmxremote.passwords file will be re-written by the server to 
replace all plain text passwords with hashed passwords when the file 
is read by the server."


line 35: "Base64 encoded hash"  -> drop the "Base64" in this line 
isn't needed and

make it seems like it should appear as 1 field instead of 2 or 3.

37+: The syntax of the file may be clearer if it includes the 
complete syntax in (line 39) not

just the password/hash fragment.

Line 41:  "W = spaces"; above "tabs" are allowed as a delimiter; it 
would be good to be consistent
and include the usualy white-space characters in the set, be as 
specific as possible.

Is this the same set of whitespace used by Regex '\\s'.
Only spaces and tabs are allowed. '\s' matches newline as well hence 
not allowed.


45: "java platform""  ->   "MD5, SDA-1, SHA-256 are supported 
algorithms."


49: be more specific about 'hashing is requested'  how?  Refer to 
the management.properties

  com.sun.management.jmxremote.password.hash value.



51:  "replace hashed" -> "replace *the *hashed"
52: "with clear text or new" -> "with the clear text or the new"
52: "If new password" -> "If the new password"
53: "when new login" -> "when a new login"

60: "User generated" -> "A User generated"

67: Will the file be ignored if it has the wrong permissions. (With 
a logged message)

Addressed all the above review comments.


* management.properties

306: "(Case for true/false ignored)"  - what does this mean; I think 
it can be removed.


307: missing period at the end of the sentence.
309: "in password file" -> "in the password file"


Done.


* FileLoginModule.java

102: can this match better the similar name in the 
management.properties if it has the same function:

    com.sun.management.jmxremote.password.hash
Are you suggesting that 'hashPassword' be renamed to something 
similar to com.sun.management.jmxremote.password.hash? Variable names 
cannot be similar to property names since property names are long and 
provide complete context which local variables need not have to do.
the suffix should be the same in all pl

Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-10-03 Thread Harsha Wardhana B

Hi Roger,

Thanks for the detailed review. Below is the webrev addressing all the 
review comments.


http://cr.openjdk.java.net/~hb/5016517/webrev.01/

-Harsha


On Tuesday 25 April 2017 10:56 PM, Roger Riggs wrote:

Hi Harsha,

Thanks for this important improvement. Comments:


* jmxremote.password.template:
  "Passwords will be hashed by server if they are in clear." Perhaps 
should be more explicit:


   "The jmxremote.passwords file will be re-written by the server to 
replace all plain text passwords with hashed passwords when the file 
is read by the server."


line 35: "Base64 encoded hash"  -> drop the "Base64" in this line 
isn't needed and

make it seems like it should appear as 1 field instead of 2 or 3.

37+: The syntax of the file may be clearer if it includes the complete 
syntax in (line 39) not

just the password/hash fragment.

Line 41:  "W = spaces"; above "tabs" are allowed as a delimiter; it 
would be good to be consistent
and include the usualy white-space characters in the set, be as 
specific as possible.

Is this the same set of whitespace used by Regex '\\s'.
Only spaces and tabs are allowed. '\s' matches newline as well hence not 
allowed.


45: "java platform""  ->   "MD5, SDA-1, SHA-256 are supported 
algorithms."


49: be more specific about 'hashing is requested'  how?  Refer to the 
management.properties

  com.sun.management.jmxremote.password.hash value.



51:  "replace hashed" -> "replace *the *hashed"
52: "with clear text or new" -> "with the clear text or the new"
52: "If new password" -> "If the new password"
53: "when new login" -> "when a new login"

60: "User generated" -> "A User generated"

67: Will the file be ignored if it has the wrong permissions. (With a 
logged message)

Addressed all the above review comments.


* management.properties

306: "(Case for true/false ignored)"  - what does this mean; I think 
it can be removed.


307: missing period at the end of the sentence.
309: "in password file" -> "in the password file"


Done.


* FileLoginModule.java

102: can this match better the similar name in the 
management.properties if it has the same function:

    com.sun.management.jmxremote.password.hash
Are you suggesting that 'hashPassword' be renamed to something similar 
to com.sun.management.jmxremote.password.hash? Variable names cannot be 
similar to property names since property names are long and provide 
complete context which local variables need not have to do.
103: "replaces clear text passwords" -> "replaces each clear text 
password"

104: indent to match previous  enteries.

* JMXPluggableAuthenticator.java

119: There is no need to copy the password to a new local
It is required since variables accessed from inner class must be final 
or effectively final.


128: add a space after ","

256 private static final String HASH_PASSWORDS =
257 "jmx.remote.x.password.file.hash";

The name ".hash" part does not clearly communicate that passwords are 
to be hashed.

"hashPasswords" might be more self explanatory.

Changed it to "jmx.remote.x.password.file.hashpassword".

Also, can this be NOT duplicated here and in ConnectorBootStrap.java?
The property names used in ConnectorBootStrap follows the convention 
used in management.properties file - 'com.sun.management.*'. For 
environment variables for a JMXConnector "jmx.remote.x.*" convention is 
used . Hence they cannot be duplicated.



* ConnectorBootStrap.java:
 482: Add space after ","s; no spaces before.

770: use the same name for the option/property if possible to avoid 
confusion.

Not possible as explained above.


770:  if the HASH_PASSWORDS static is appropriate use it instead of 
literal "true".
DefaultValues.HASH_PASSWORDS static is set to 'true' and can be used. 
However using literal "true" is more readable than using the static.


* HashedPasswordManager

80-83: The fields can be final and use the constructor to initialize 
in all cases and make the class final

to avoid unintentional subclassing.


113: canWriteToFile:   It should be made clear in the template that 
*both* the Security policy
   and the file access value are used to check that the file can be 
updated.

Made it explicit in template as well as code comments.


200: loadPasswords() - should this confirm the access to the file is 
allowed and it has

the correct file access before reading?
Not really required. Appropriate exceptions are thrown if file cannot be 
accessed.


Is the re-writing of the passwords intended to be done by a 
'priveleged' system.

Does this need doPrivileged?

I am not sure. Maybe it will be covered in the security review.


* HashedPasswordFil

Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-12 Thread Harsha Wardhana B

Hi Kirk,Erik,

The current JEP addresses the first use-case. Second use case can be 
realized by adding a JMXConnector that operates over REST APIs provided 
by the current JEP. But that is outside the scope of this JEP.


-Harsha


On Tuesday 12 September 2017 04:27 PM, Kirk Pepperdine wrote:


On Sep 12, 2017, at 12:44 PM, Erik Gahlin <erik.gah...@oracle.com 
<mailto:erik.gah...@oracle.com>> wrote:


I guess there are two use cases:

1) Simple interoperability with other languages.
2) A drop in replacement for RMI

Can a JMX connector be written that support both use cases? I don't 
know, but if not it could be that we need both a connector and an 
adapter.


I think if you were to extend JMXConnector to wrap the REST API you 
might be able to expose both. But I’m not sure it would be a great 
solution. I think a second JEP would be a better option.


— Kirk



Erik


Hi Kirk,

I guess the term 'connector' here is loosely applied. When I say 
connector, I mean the connector that provides implementation of the 
package below,


https://docs.oracle.com/javase/8/docs/api/javax/management/remote/package-summary.html

RMIConnector is one implementation of above connector.


On Tuesday 12 September 2017 12:56 PM, Kirk Pepperdine wrote:

Hi Harsha,

From Chapter 5 of the JMX documentation. "Many different 
implementations of connectors are possible. In particular, there 
are many possibilities for the protocol used to communicate over a 
connection between client and server.”


It goes on in the Generic Connector section under "User-Defined 
Protocols” to say; "While the RMI connector must be present in 
every implementation of the JMX Remote API, you can also implement 
a connector based on a protocol that is not defined in the JMX 
Remote API standard. A typical example of this is a connector based 
on a protocol that uses HTTP/S. Other protocols are also possible. 
The JMX specification describes how to implement a connector based 
on a user-defined protocol.”


Unless I’m missing something, this all suggests that there is 
nothing inherently wrong is using REST behind a JMXConnector.
I hope above should clarify what I refer to when I say JMXConnector. 
In that sense, REST APIs alone cannot work as connector. In fact, it 
stands parallel to connector, as in it directly wraps the 
MBeanServer and does not wrap any JMXConnector. The JEP has detailed 
information about where the REST adapter sits in the JMX architecture.


Are you suggesting that we implement a JMXConnector that works over 
REST?


As written this JEP pretty much looks like Jolokia. Jolokia is a 
great project and as such I fail to see the benefits of simply 
duplicating it. I’d also argue that the usefulness of that project 
has been some what muted because it is not a drop in replacement 
for the standard RMI connector meaning that one has to modify an 
entire tool chain just to make use of it. However, creating a REST 
based JMXConnector would be immediately useful.
As an aside, Jus last week I started on a JMXConnector that uses a 
shared memory segment for communications. Of course this 
implementation would only be available for local communications but 
it offers some advantages over using a socket based protocol, even 
if that comms is over local loopback.


Kind regards,
Kirk Pepperdine


Thanks
Harsha




On Sep 12, 2017, at 9:04 AM, Harsha Wardhana B 
<harsha.wardhan...@oracle.com> wrote:


Hi Kirk,

REST APIs work as an adapter and cannot work as a connector. To 
quote from the JEP,



The REST adapter is a part of the Distributed services level. 
Connectors mirror the interfaces of agent level services to 
remote clients, whereas adapters transform agent level services 
to different protocol. The proposed functionality will transform 
Agent level services to REST APIs, hence the name "REST adapter".
A connector *must* adhere to the JMX remoting spec. REST APIs 
cannot adhere to that because they expose APIs via HTTP and not 
Java. Hence it is called an Adapter and not a connector. It can 
never work as a 'drop-in' replacement for JMX/RMI Connector. 
Existing tools using using RMIConnector will have to be modified 
to use REST APIs.


The current JEP does not allow all of the CRUD operations on 
MBeans. In the spirit of keeping the APIs language agnostic, only 
read/write is supported. It is not possible to specify 
create/delete REST APIs for JMX without incorporating language 
specific features. I would welcome discussions around including 
create/delete APIs for MBeans.


In lieu of the above, as of now REST adapter cannot exist 
independently and will have to live along-side RMIConnector.


-Harsha


On Monday 11 September 2017 09:05 PM, Kirk Pepperdine wrote:

Hi Harsha,

The only reason I mentioned Jolokia is that it’s a project that 
usefulness is some what limited because it is *not* a compliment 
JMX connector and as such cannot be used as a straight drop-in 
replacement for th

Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-12 Thread Harsha Wardhana B

Hi Kirk,

I guess the term 'connector' here is loosely applied. When I say 
connector, I mean the connector that provides implementation of the 
package below,


https://docs.oracle.com/javase/8/docs/api/javax/management/remote/package-summary.html

RMIConnector is one implementation of above connector.


On Tuesday 12 September 2017 12:56 PM, Kirk Pepperdine wrote:

Hi Harsha,

From Chapter 5 of the JMX documentation. "Many different 
implementations of connectors are possible. In particular, there are 
many possibilities for the protocol used to communicate over a 
connection between client and server.”


It goes on in the Generic Connector section under "User-Defined 
Protocols” to say; "While the RMI connector must be present in every 
implementation of the JMX Remote API, you can also implement a 
connector based on a protocol that is not defined in the JMX Remote 
API standard. A typical example of this is a connector based on a 
protocol that uses HTTP/S. Other protocols are also possible. The JMX 
specification describes how to implement a connector based on a 
user-defined protocol.”


Unless I’m missing something, this all suggests that there is 
nothing inherently wrong is using REST behind a JMXConnector.
I hope above should clarify what I refer to when I say JMXConnector. In 
that sense, REST APIs alone cannot work as connector. In fact, it stands 
parallel to connector, as in it directly wraps the MBeanServer and does 
not wrap any JMXConnector. The JEP has detailed information about where 
the REST adapter sits in the JMX architecture.


Are you suggesting that we implement a JMXConnector that works over REST?


As written this JEP pretty much looks like Jolokia. Jolokia is a great 
project and as such I fail to see the benefits of simply duplicating 
it. I’d also argue that the usefulness of that project has been some 
what muted because it is not a drop in replacement for the standard 
RMI connector meaning that one has to modify an entire tool chain just 
to make use of it. However, creating a REST based JMXConnector would 
be immediately useful.
As an aside, Jus last week I started on a JMXConnector that uses a 
shared memory segment for communications. Of course this 
implementation would only be available for local communications but it 
offers some advantages over using a socket based protocol, even if 
that comms is over local loopback.


Kind regards,
Kirk Pepperdine


Thanks
Harsha




On Sep 12, 2017, at 9:04 AM, Harsha Wardhana B 
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>> 
wrote:


Hi Kirk,

REST APIs work as an adapter and cannot work as a connector. To quote 
from the JEP,



The REST adapter is a part of the Distributed services level. 
Connectors mirror the interfaces of agent level services to remote 
clients, whereas adapters transform agent level services to 
different protocol. The proposed functionality will transform Agent 
level services to REST APIs, hence the name "REST adapter".
A connector *must* adhere to the JMX remoting spec. REST APIs cannot 
adhere to that because they expose APIs via HTTP and not Java. Hence 
it is called an Adapter and not a connector. It can never work as a 
'drop-in' replacement for JMX/RMI Connector. Existing tools using 
using RMIConnector will have to be modified to use REST APIs.


The current JEP does not allow all of the CRUD operations on MBeans. 
In the spirit of keeping the APIs language agnostic, only read/write 
is supported. It is not possible to specify create/delete REST APIs 
for JMX without incorporating language specific features. I would 
welcome discussions around including create/delete APIs for MBeans.


In lieu of the above, as of now REST adapter cannot exist 
independently and will have to live along-side RMIConnector.


-Harsha


On Monday 11 September 2017 09:05 PM, Kirk Pepperdine wrote:

Hi Harsha,

The only reason I mentioned Jolokia is that it’s a project that 
usefulness is some what limited because it is *not* a compliment JMX 
connector and as such cannot be used as a straight drop-in 
replacement for the current RMI based connector. Is your plan here 
to make it a fully compliant connector so that we could configure 
tooling such as the MBean viewers in jConsole and VisualVM (or JMC 
for that matter) to use a restful connector instead of an RMI based 
connector? IMHO, doing so would represent a huge win as I know of 
quite a few projects that cannot or will not use JMX because of it’s 
reliance on RMI.


Consolidating all of the options under a single flag looks like 
another interesting win.


Kind regards,
Kirk



On Sep 11, 2017, at 4:08 PM, Harsha Wardhana B 
<harsha.wardhan...@oracle.com 
<mailto:harsha.wardhan...@oracle.com>> wrote:


Hi Erik,


On Monday 11 September 2017 07:14 PM, Erik Gahlin wrote:

Hi Harsha,

I haven't looked at Jolokia, or know what is the most reasonable 
approach in this case, but as a principle

Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-12 Thread Harsha Wardhana B

Hi Kirk,

REST APIs work as an adapter and cannot work as a connector. To quote 
from the JEP,


The REST adapter is a part of the Distributed services level. 
Connectors mirror the interfaces of agent level services to remote 
clients, whereas adapters transform agent level services to different 
protocol. The proposed functionality will transform Agent level 
services to REST APIs, hence the name "REST adapter".
A connector *must* adhere to the JMX remoting spec. REST APIs cannot 
adhere to that because they expose APIs via HTTP and not Java. Hence it 
is called an Adapter and not a connector. It can never work as a 
'drop-in' replacement for JMX/RMI Connector. Existing tools using using 
RMIConnector will have to be modified to use REST APIs.


The current JEP does not allow all of the CRUD operations on MBeans. In 
the spirit of keeping the APIs language agnostic, only read/write is 
supported. It is not possible to specify create/delete REST APIs for JMX 
without incorporating language specific features. I would welcome 
discussions around including create/delete APIs for MBeans.


In lieu of the above, as of now REST adapter cannot exist independently 
and will have to live along-side RMIConnector.


-Harsha


On Monday 11 September 2017 09:05 PM, Kirk Pepperdine wrote:

Hi Harsha,

The only reason I mentioned Jolokia is that it’s a project that 
usefulness is some what limited because it is *not* a compliment JMX 
connector and as such cannot be used as a straight drop-in replacement 
for the current RMI based connector. Is your plan here to make it a 
fully compliant connector so that we could configure tooling such as 
the MBean viewers in jConsole and VisualVM (or JMC for that matter) to 
use a restful connector instead of an RMI based connector? IMHO, doing 
so would represent a huge win as I know of quite a few projects that 
cannot or will not use JMX because of it’s reliance on RMI.


Consolidating all of the options under a single flag looks like 
another interesting win.


Kind regards,
Kirk



On Sep 11, 2017, at 4:08 PM, Harsha Wardhana B 
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>> 
wrote:


Hi Erik,


On Monday 11 September 2017 07:14 PM, Erik Gahlin wrote:

Hi Harsha,

I haven't looked at Jolokia, or know what is the most reasonable 
approach in this case, but as a principle, I think we should strive 
for the best possible design rather than trying to be compatible 
with third party tools.
Agreed. That will always be the first priority. That is the reason 
HTTP GET interfaces will not be changed. I am undecided if the POST 
payloads need to be changed (without compromising the REST design 
principles) to increase adoption of this feature.


How will the command line look like to start the agent with the rest 
adapter?


In the past there have been discussions about adding syntactic sugar 
for -Dcom.sun.management, i.e.


-Xmanagement:ssl=false,port=7091,authenticate=false

instead of

-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=7091
-Dcom.sun.management.jmxremote.authenticate=false

which is hard to remember, cumbersome to write and error prone since 
the parameters are not validated. If we are adding support for REST, 
it could perhaps be default, i.e.


-Xmanagement:ssl=false,authenticate=false,port=80

If you want to use JMX over RMI you would specify protocol:

-Xmanagement:ssl=false,port=7091,authenticate=false,protocol=rmi
Yes. There is an enhancement request to add the -Xmanagemet:* 
syntatic sugar for -Dcom.sun.management.jmxremote.* flags. REST 
adapter will use one of the above flags though I haven't thought of 
the exact name for it yet. I will update the JEP with the details of 
the flag shortly.


Has there been any thoughts about JMX notifications?

Notifications will not be supported in this JEP.

  * MBean Notifications are not a widely used feature and will not be
supported via the REST adapter.



I know it is outside the scope of the JEP, but I think we should 
take it into consideration when doing the design, so the 
functionality could be added on later without too much difficulty.
Notifications can be added without modifying the current design too 
much. If required, it will be worked upon via an enhancement request.


Thanks
Erik


Thanks
Harsha


Hi Martin,

In my opinion, the interfaces exposed by current JEP are lot closer 
to REST style than the interfaces exposed by Jolokia.


For instance, HTTP GET by default should be used to read resources, 
but it is made part of URL in Jolokia interfaces.


/read///

I would wait on opinions from more people before considering 
changing the current interfaces.


Thanks
-Harsha

On Wednesday 06 September 2017 11:40 AM, Martin Skarsaune wrote:

Hello

Would one at least consider adopting the same URL paths and 
payloads as Jolokia? This could make life a lot easier for third 
party tools that connect to it.


Best Regards

Martin Skarsa

Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-11 Thread Harsha Wardhana B

Hi Erik,


On Monday 11 September 2017 07:14 PM, Erik Gahlin wrote:

Hi Harsha,

I haven't looked at Jolokia, or know what is the most reasonable 
approach in this case, but as a principle, I think we should strive 
for the best possible design rather than trying to be compatible with 
third party tools.
Agreed. That will always be the first priority. That is the reason HTTP 
GET interfaces will not be changed. I am undecided if the POST payloads 
need to be changed (without compromising the REST design principles) to 
increase adoption of this feature.


How will the command line look like to start the agent with the rest 
adapter?


In the past there have been discussions about adding syntactic sugar 
for -Dcom.sun.management, i.e.


-Xmanagement:ssl=false,port=7091,authenticate=false

instead of

-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=7091
-Dcom.sun.management.jmxremote.authenticate=false

which is hard to remember, cumbersome to write and error prone since 
the parameters are not validated. If we are adding support for REST, 
it could perhaps be default, i.e.


-Xmanagement:ssl=false,authenticate=false,port=80

If you want to use JMX over RMI you would specify protocol:

-Xmanagement:ssl=false,port=7091,authenticate=false,protocol=rmi
Yes. There is an enhancement request to add the -Xmanagemet:* syntatic 
sugar for -Dcom.sun.management.jmxremote.* flags. REST adapter will use 
one of the above flags though I haven't thought of the exact name for it 
yet. I will update the JEP with the details of the flag shortly.


Has there been any thoughts about JMX notifications?

Notifications will not be supported in this JEP.

 * MBean Notifications are not a widely used feature and will not be
   supported via the REST adapter.



I know it is outside the scope of the JEP, but I think we should take 
it into consideration when doing the design, so the functionality 
could be added on later without too much difficulty.
Notifications can be added without modifying the current design too 
much. If required, it will be worked upon via an enhancement request.


Thanks
Erik


Thanks
Harsha


Hi Martin,

In my opinion, the interfaces exposed by current JEP are lot closer 
to REST style than the interfaces exposed by Jolokia.


For instance, HTTP GET by default should be used to read resources, 
but it is made part of URL in Jolokia interfaces.


/read///

I would wait on opinions from more people before considering changing 
the current interfaces.


Thanks
-Harsha

On Wednesday 06 September 2017 11:40 AM, Martin Skarsaune wrote:

Hello

Would one at least consider adopting the same URL paths and payloads 
as Jolokia? This could make life a lot easier for third party tools 
that connect to it.


Best Regards

Martin Skarsaune

ons. 6. sep. 2017 kl. 07:04 skrev Harsha Wardhana B 
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>>:


Hi Kirk,

Yes. Jolokia was considered and is listed as an alternative in
the JEP.

  * Jolokia can serve as a viable alternative but can be bulky.
We are looking for simple and lightweight solution.


-Harsha

On Wednesday 06 September 2017 10:21 AM, Kirk Pepperdine wrote:

Hi,

Have you run into this project?https://jolokia.org. Unfortunately it’s not 
exactly a drop in replacement for the standard RMI based JMX connector but it’s 
not far off.

Kind regards,
Kirk


On Sep 5, 2017, at 6:30 PM, Erik Gahlin<erik.gah...@oracle.com> 
<mailto:erik.gah...@oracle.com>  wrote:

Hi Harsha,

Looping in jmx-dev.


byte[], short[], int[], float[], double[]

Should long[] be included there as well?


The REST adapter will come with a simple and lightweight JSON parser.

Is this an internal parser or will it be exposed as an API?

If so, how does it relate to JEP 198: Light-Weight JSON API?
http://openjdk.java.net/jeps/198

Will com.sun.net.httpserver.HttpServer be used to serve the requests?

Thanks
Erik


Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM requires 
a Java client. Language-agnostic access to MBeans will require spawning a Java 
client which can be cumbersome. The proposed JEP allows MBeans to be accessed 
in a language/platform-independent, ubiquitous and seamless manner.

Thanks
-Harsha










Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-07 Thread Harsha Wardhana B

Hi Martin,

I will take a second look at POST payloads.

Thanks

Harsha


On Thursday 07 September 2017 02:16 AM, Martin Skarsaune wrote:
How about POST payloads? Since they are so similar already, it would 
be a huge advantage if they could be made interchangeable.


For instance I have done some work on hawt.io <http://hawt.io> 
plugins. A typical scenario for a plugin is to set up one or more 
chained requests for read/write/exec on an MBean, and have a callback 
process the response. If the payloads were compatible, the road to 
support this new backend might not be too difficult. That would give 
this new initiative a real boost over traditional JMX connections.
Otherwise one would have to impose an additional layer of complexity 
to bridge the difference.


I suppose you know these tools very well already. There is by the way 
a presentation on JMX, Jolokia and hawt.io <http://hawt.io> at 
JavaZone in a weeks time, and the recording is usually made available 
just a few hours later: 
https://2017.javazone.no/program/bbe08ad550174e16abd954733e018590


Best regards

Martin

ons. 6. sep. 2017 kl. 08:47 skrev Harsha Wardhana B 
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>>:


Hi Martin,

In my opinion, the interfaces exposed by current JEP are lot
closer to REST style than the interfaces exposed by Jolokia.

For instance, HTTP GET by default should be used to read
resources, but it is made part of URL in Jolokia interfaces.

/read///


I would wait on opinions from more people before considering
changing the current interfaces.

Thanks

-Harsha


On Wednesday 06 September 2017 11:40 AM, Martin Skarsaune wrote:

Hello

Would one at least consider adopting the same URL paths and
payloads as Jolokia? This could make life a lot easier for third
party tools that connect to it.

Best Regards

Martin Skarsaune

ons. 6. sep. 2017 kl. 07:04 skrev Harsha Wardhana B
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>>:

Hi Kirk,

Yes. Jolokia was considered and is listed as an alternative
in the JEP.

  * Jolokia can serve as a viable alternative but can be
bulky. We are looking for simple and lightweight solution.


-Harsha

On Wednesday 06 September 2017 10:21 AM, Kirk Pepperdine wrote:

Hi,

Have you run into this project?https://jolokia.org. Unfortunately it’s 
not exactly a drop in replacement for the standard RMI based JMX connector but 
it’s not far off.

Kind regards,
Kirk


On Sep 5, 2017, at 6:30 PM, Erik Gahlin<erik.gah...@oracle.com> 
<mailto:erik.gah...@oracle.com>  wrote:

Hi Harsha,

Looping in jmx-dev.


byte[], short[], int[], float[], double[]

Should long[] be included there as well?


The REST adapter will come with a simple and lightweight JSON parser.

Is this an internal parser or will it be exposed as an API?

If so, how does it relate to JEP 198: Light-Weight JSON API?
http://openjdk.java.net/jeps/198

Will com.sun.net.httpserver.HttpServer be used to serve the requests?

Thanks
Erik


Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM 
requires a Java client. Language-agnostic access to MBeans will require 
spawning a Java client which can be cumbersome. The proposed JEP allows MBeans 
to be accessed in a language/platform-independent, ubiquitous and seamless 
manner.

Thanks
-Harsha








Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-06 Thread Harsha Wardhana B

Hi Martin,

In my opinion, the interfaces exposed by current JEP are lot closer to 
REST style than the interfaces exposed by Jolokia.


For instance, HTTP GET by default should be used to read resources, but 
it is made part of URL in Jolokia interfaces.


/read///


I would wait on opinions from more people before considering changing 
the current interfaces.


Thanks
-Harsha

On Wednesday 06 September 2017 11:40 AM, Martin Skarsaune wrote:

Hello

Would one at least consider adopting the same URL paths and payloads 
as Jolokia? This could make life a lot easier for third party tools 
that connect to it.


Best Regards

Martin Skarsaune

ons. 6. sep. 2017 kl. 07:04 skrev Harsha Wardhana B 
<harsha.wardhan...@oracle.com <mailto:harsha.wardhan...@oracle.com>>:


Hi Kirk,

Yes. Jolokia was considered and is listed as an alternative in the
JEP.

  * Jolokia can serve as a viable alternative but can be bulky. We
are looking for simple and lightweight solution.


-Harsha

On Wednesday 06 September 2017 10:21 AM, Kirk Pepperdine wrote:

Hi,

Have you run into this project?https://jolokia.org. Unfortunately it’s not 
exactly a drop in replacement for the standard RMI based JMX connector but it’s 
not far off.

Kind regards,
Kirk


On Sep 5, 2017, at 6:30 PM, Erik Gahlin<erik.gah...@oracle.com> 
<mailto:erik.gah...@oracle.com>  wrote:

Hi Harsha,

Looping in jmx-dev.


byte[], short[], int[], float[], double[]

Should long[] be included there as well?


The REST adapter will come with a simple and lightweight JSON parser.

Is this an internal parser or will it be exposed as an API?

If so, how does it relate to JEP 198: Light-Weight JSON API?
http://openjdk.java.net/jeps/198

Will com.sun.net.httpserver.HttpServer be used to serve the requests?

Thanks
Erik


Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM requires 
a Java client. Language-agnostic access to MBeans will require spawning a Java 
client which can be cumbersome. The proposed JEP allows MBeans to be accessed 
in a language/platform-independent, ubiquitous and seamless manner.

Thanks
-Harsha






Re: JEP review : JDK-8171311 - REST APIs for JMX

2017-09-05 Thread Harsha Wardhana B

Hi Kirk,

Yes. Jolokia was considered and is listed as an alternative in the JEP.

 * Jolokia can serve as a viable alternative but can be bulky. We are
   looking for simple and lightweight solution.


-Harsha

On Wednesday 06 September 2017 10:21 AM, Kirk Pepperdine wrote:

Hi,

Have you run into this project? https://jolokia.org. Unfortunately it’s not 
exactly a drop in replacement for the standard RMI based JMX connector but it’s 
not far off.

Kind regards,
Kirk


On Sep 5, 2017, at 6:30 PM, Erik Gahlin  wrote:

Hi Harsha,

Looping in jmx-dev.


byte[], short[], int[], float[], double[]

Should long[] be included there as well?


The REST adapter will come with a simple and lightweight JSON parser.

Is this an internal parser or will it be exposed as an API?

If so, how does it relate to JEP 198: Light-Weight JSON API?
http://openjdk.java.net/jeps/198

Will com.sun.net.httpserver.HttpServer be used to serve the requests?

Thanks
Erik


Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM requires a 
Java client. Language-agnostic access to MBeans will require spawning a Java 
client which can be cumbersome. The proposed JEP allows MBeans to be accessed 
in a language/platform-independent, ubiquitous and seamless manner.

Thanks
-Harsha






Re: jmx-dev JEP review : JDK-8171311 - REST APIs for JMX

2017-09-05 Thread Harsha Wardhana B

Hi Erik,


On Tuesday 05 September 2017 10:00 PM, Erik Gahlin wrote:

Hi Harsha,

Looping in jmx-dev.

> byte[], short[], int[], float[], double[]

Should long[] be included there as well?

Yes. Thanks.


> The REST adapter will come with a simple and lightweight JSON parser.

Is this an internal parser or will it be exposed as an API?

It is an internal parser.


If so, how does it relate to JEP 198: Light-Weight JSON API?
http://openjdk.java.net/jeps/198

It is written from scratch using JavaCC and is not related to above JEP.


Will com.sun.net.httpserver.HttpServer be used to serve the requests?

Yes.



Thanks
Erik


Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM 
requires a Java client. Language-agnostic access to MBeans will 
require spawning a Java client which can be cumbersome. The proposed 
JEP allows MBeans to be accessed in a language/platform-independent, 
ubiquitous and seamless manner.


Thanks
-Harsha





- Harsha


JEP review : JDK-8171311 - REST APIs for JMX

2017-09-04 Thread Harsha Wardhana B

Hi All,

Please review the JEP for REST APIs for JMX :
https://bugs.openjdk.java.net/browse/JDK-8171311

The JEP aims at providing RESTful web interfaces to MBeans.

Access to MBeans registered in a MBeanServer running inside a JVM 
requires a Java client. Language-agnostic access to MBeans will require 
spawning a Java client which can be cumbersome. The proposed JEP allows 
MBeans to be accessed in a language/platform-independent, ubiquitous and 
seamless manner.


Thanks
-Harsha




Re: RFR : JDK-8186224 javax/management/remote/mandatory/subjectDelegation/* fail with java.security.AccessControlException

2017-08-24 Thread Harsha Wardhana B

Hi Ujwal,

The changes look good.

Thanks

Harsha


On Tuesday 22 August 2017 02:11 PM, Ujwal Vangapally wrote:

Kindly review the changes made.

Before these changes tests fail on windows if we execute them from any 
Drive other than C.


grant codebase "file:/-" {}   is granting permissions only to code 
present in C Drive on windows.


Hence changing'grant codebase "file:/-" {} ' to  grant {} will 
solve the issue by giving permissions to all drives.



https://bugs.openjdk.java.net/browse/JDK-8186224

webrev: 
http://cr.openjdk.java.net/~uvangapally/webrev/2017/8186224/webrev.00/



Thanks,

Ujwal.





Re: RFR : 8182485 - JMX connections should have configurable ObjectInputFilter

2017-06-20 Thread Harsha Wardhana B

Thanks for the review Daniel,Roger.

-Harsha


On Tuesday 20 June 2017 11:30 PM, Roger Riggs wrote:

+1

Roger


On 6/20/2017 1:24 PM, Daniel Fuchs wrote:

The fix looks good to me Harsha.

best regards,

-- daniel

On 20/06/2017 07:10, Harsha Wardhana B wrote:

Hi,

Please review the below RFE,

JDK-8182485 : JMX connections should have configurable 
ObjectInputFilter


having webrev at

http://cr.openjdk.java.net/~hb/8182485/webrev.00/

The enhancement adds ObjectInputFilter to JMX connections to 
configure filters during deserialization.


-Harsha












Re: RFR: JDK-8173180 VirtualMachine.startLocalManagementAgent() returns URI with unreliable IP address

2017-06-20 Thread Harsha Wardhana B

Hi Daniel,


On Tuesday 20 June 2017 06:39 PM, Daniel Fuchs wrote:

On 20/06/2017 12:42, Ujwal Vangapally wrote:

Thanks for the Review Daniel, Harsha.

Yes with this fix JConsole running on JDK 8 won't be able to connect 
to a process running on higher version of Java containing this change.


I think even Harsha is agreeing this, his point is that the use case 
where a client running on JDK 8 trying to connect to a process 
running on latest releases is rare. As mostly for Local Management 
both client and server will be running on same machine using same JDK 
for starting both client and server .


please correct me if this is not the case.


Well - I believe it could be quite common to use VisualVM running
on JDK 8 to connect to JDK 9 processes. JMX is all about
interoperability so I'd be very reluctant to break this 'by
default'.

Agreed.



can we have this fix with interoperability issue between versions ?


Maybe you could make the fix conditional to a system property being
defined? Also are you sure what you are proposing is the correct fix
for this issue?
It's more of a workaround than a fix as we don't see any other way to 
fix this issue.


Note that - if I'm not mistaken - you can work around the original issue
by specifying -Djava.rmi.server.hostname= on the command line.
http://docs.oracle.com/javase/8/docs/technotes/guides/rmi/javarmiproperties.html 


This will instruct RMI to put the specified  inside its stubs.
The inconvenience is that this is global (for all RMI stubs, just not
only those used by JMX) - but would that be an issue for the use case
mentioned in the bug?
We had the same consideration that setting the RMI property will change 
the Interface address for all the stubs which may not be an acceptable 
fix in this case.
One possible fix (enhancement) would be to define a JMX system property 
that will control the Interface address that goes into RMI stubs. If 
that seems like too much work, we can close this issue as 'won't fix' as 
we don't have any acceptable fix.


best regards,

-- daniel


-Harsha




Thanks,

Ujwal.



On 6/20/2017 2:40 PM, Daniel Fuchs wrote:

Hi Harsha,

Maybe I'm missing something.
How is the local agent started?

If it's started when you connect jconsole to a process
by specifying the process ID - then I suspect this will
prevent e.g. jconsole or jvisualvm running on JDK 8 to
connect to your process.

Can you verify that it's not the case?

best regards,

-- daniel

On 20/06/2017 09:11, Harsha Wardhana B wrote:

Hi Daniel,

The fix is applicable only to local JMX agent and the most common 
use case would be client and server running from same JVM.
It is highly unlikely that local JMX agent will be started to cater 
for out-of-jvm clients.


I don't see how introducing this fix can cause new interoperability 
problems. Can you please elaborate?


-Harsha

On Monday 19 June 2017 10:23 PM, Daniel Fuchs wrote:

Hi,

If I'm not mistaken then this will make it impossible
for earlier release to interoperate with newer releases
as the LocalRMIClientSocketFactory class will not be
present the client tries to deserialize the stub.

best regards,

-- daniel

On 19/06/2017 11:52, Ujwal Vangapally wrote:

Hi,

Kindly review the fix for bug below

https://bugs.openjdk.java.net/browse/JDK-8173180

webrev: 
http://cr.openjdk.java.net/~uvangapally/webrev/2017/8173180/webrev.00/ 



Thanks,

Ujwal













Re: RFR: JDK-8173180 VirtualMachine.startLocalManagementAgent() returns URI with unreliable IP address

2017-06-20 Thread Harsha Wardhana B

Hi Daniel,

The fix is applicable only to local JMX agent and the most common use 
case would be client and server running from same JVM.
It is highly unlikely that local JMX agent will be started to cater for 
out-of-jvm clients.


I don't see how introducing this fix can cause new interoperability 
problems. Can you please elaborate?


-Harsha

On Monday 19 June 2017 10:23 PM, Daniel Fuchs wrote:

Hi,

If I'm not mistaken then this will make it impossible
for earlier release to interoperate with newer releases
as the LocalRMIClientSocketFactory class will not be
present the client tries to deserialize the stub.

best regards,

-- daniel

On 19/06/2017 11:52, Ujwal Vangapally wrote:

Hi,

Kindly review the fix for bug below

https://bugs.openjdk.java.net/browse/JDK-8173180

webrev: 
http://cr.openjdk.java.net/~uvangapally/webrev/2017/8173180/webrev.00/


Thanks,

Ujwal







RFR : 8182485 - JMX connections should have configurable ObjectInputFilter

2017-06-20 Thread Harsha Wardhana B

Hi,

Please review the below RFE,

JDK-8182485 : JMX connections should have configurable ObjectInputFilter

having webrev at

http://cr.openjdk.java.net/~hb/8182485/webrev.00/

The enhancement adds ObjectInputFilter to JMX connections to configure 
filters during deserialization.


-Harsha






Re: RFR: JDK-8178508 Co-locate remaining MM tests

2017-06-04 Thread Harsha Wardhana B

Hi Ujwal,

Looks fine.

-Harsha


On Thursday 01 June 2017 04:55 PM, Ujwal Vangapally wrote:


Gentle reminder.

Thanks,

Ujwal.


On 5/31/2017 10:32 AM, Ujwal Vangapally wrote:


Kindly review the changes made for below bug

converted tonga test to JTREG test

added an additional assert statement for verifying 
setusageThreshold() operation is successful


https://bugs.openjdk.java.net/browse/JDK-8178508

tonga test case is currently at this path :

http://sqe-hgi.us.oracle.com/hg/index.cgi/testbase/javase/functional/9/vm/file/tip/src/nsk/regression/b6653214/  



webrev :
http://cr.openjdk.java.net/~uvangapally/webrev/2017/8178508/webrev.00/

Thanks,

Ujwal.






Re: RFR: JDK-6515161 If remote removeNotificationListener gets SecurityException, client no longer gets notifications

2017-05-08 Thread Harsha Wardhana B

Hi Daniel,

The term 'listenerid' is used in conjunction with method name/object 
field which adds context about the term 'listenerid'. Having a 
standalone method name as getClientListenerId is less ambiguous compared 
to method name : getListenerId.


I don't really have a strong opinion on this and am okay with either names.

-Harsha


On Monday 08 May 2017 03:16 PM, Daniel Fuchs wrote:

On 08/05/2017 09:45, Ujwal Vangapally wrote:

Thanks for the Review Daniel, Harsha

Please find the new webrev incorporating the review comments

webrev :
http://cr.openjdk.java.net/~uvangapally/webrev/2017/6515161/webrev.01/


Looks good. In retrospect I wonder if renaming
getListenerIds/getListenerId into 
getClientListenerIds/getClientListenerId

was such a good idea given that 'listenerId' is an established
terminology in the specification [1] [2] (and 'listenerId' is used all
over the place in ClientNotifForwarder anyway).

Harsha, what do you think?

best regards,

-- daniel

[1] See @return in 
http://download.java.net/java/jdk9/docs/api/javax/management/remote/rmi/RMIConnection.html#addNotificationListeners-javax.management.ObjectName:A-java.rmi.MarshalledObject:A-javax.security.auth.Subject:A-

[2] see @param listenerIds in
http://download.java.net/java/jdk9/docs/api/javax/management/remote/rmi/RMIConnection.html#removeNotificationListeners-javax.management.ObjectName-java.lang.Integer:A-javax.security.auth.Subject- 






Thanks,

Ujwal


On 5/8/2017 12:03 PM, Daniel Fuchs wrote:

Hi Ujwal,

For consistency I think the new getListenerIds method should:

a) either return an array of Integer, even if it contains only 1
Integer:

  1. The name of the method implies that an array is returned
  2. You will need the array when you call
 connection.removeNotificationListeners anyway.

or b) the other possibility is to remove the 's' at the end of the
method.

Both would be acceptable.

best regards,

-- daniel

On 04/05/17 07:59, Ujwal Vangapally wrote:

corrected webrev link :
http://cr.openjdk.java.net/~uvangapally/webrev/2017/6515161/webrev.00/


On 5/4/2017 12:14 PM, Ujwal Vangapally wrote:


Kindly review the changes made for below bug

Problem description and solution are explained in comments section

https://bugs.openjdk.java.net/browse/JDK-6515161

diff for*ClientNotifForwarder.java *might be a bit confusing as it
shows the method name

removeNotificationListener is modified to getListenerIds and new
method removeNotificationListener is introduced.

Actual change is new method getListenerIds is introduced and it is
called in removeNotificationListener method without

affecting the functionality of removeNotificationListener.

webrev :
cr.openjdk.java.net/~uvangapally/webrev/2017/6515161/webrev.00/

Thanks,

Ujwal,













Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-05-07 Thread Harsha Wardhana B

Hello,

Could I get one more reviewer for this enhancement?

-Harsha


On Thursday 27 April 2017 12:06 PM, Harsha Wardhana B wrote:

Hi Roger,

Thanks for the detailed review. I will wait for more review comments 
before incorporating the ones below.


-Harsha


On Tuesday 25 April 2017 10:56 PM, Roger Riggs wrote:

Hi Harsha,

Thanks for this important improvement. Comments:


* jmxremote.password.template:
  "Passwords will be hashed by server if they are in clear." Perhaps 
should be more explicit:


   "The jmxremote.passwords file will be re-written by the server to 
replace all plain text passwords with hashed passwords when the file 
is read by the server."


line 35: "Base64 encoded hash"  -> drop the "Base64" in this line 
isn't needed and

make it seems like it should appear as 1 field instead of 2 or 3.

37+: The syntax of the file may be clearer if it includes the 
complete syntax in (line 39) not

just the password/hash fragment.

Line 41:  "W = spaces"; above "tabs" are allowed as a delimiter; it 
would be good to be consistent
and include the usualy white-space characters in the set, be as 
specific as possible.

Is this the same set of whitespace used by Regex '\\s'.

45: "java platform""  ->   "MD5, SDA-1, SHA-256 are supported 
algorithms."


49: be more specific about 'hashing is requested'  how?  Refer to the 
management.properties

  com.sun.management.jmxremote.password.hash value.



51:  "replace hashed" -> "replace *the *hashed"
52: "with clear text or new" -> "with the clear text or the new"
52: "If new password" -> "If the new password"
53: "when new login" -> "when a new login"

60: "User generated" -> "A User generated"

67: Will the file be ignored if it has the wrong permissions. (With a 
logged message)


* management.properties

306: "(Case for true/false ignored)"  - what does this mean; I think 
it can be removed.


307: missing period at the end of the sentence.
309: "in password file" -> "in the password file"


* FileLoginModule.java

102: can this match better the similar name in the 
management.properties if it has the same function:

com.sun.management.jmxremote.password.hash
103: "replaces clear text passwords" -> "replaces each clear text 
password"

104: indent to match previous  enteries.

* JMXPluggableAuthenticator.java

119: There is no need to copy the password to a new local

128: add a space after ","

256 private static final String HASH_PASSWORDS =
257 "jmx.remote.x.password.file.hash";

The name ".hash" part does not clearly communicate that passwords are 
to be hashed.

"hashPasswords" might be more self explanatory.
Also, can this be NOT duplicated here and in ConnectorBootStrap.java?


* ConnectorBootStrap.java:
 482: Add space after ","s; no spaces before.

770: use the same name for the option/property if possible to avoid 
confusion.


770:  if the HASH_PASSWORDS static is appropriate use it instead of 
literal "true".


* HashedPasswordManager

80-83: The fields can be final and use the constructor to initialize 
in all cases and make the class final

to avoid unintentional subclassing.


113: canWriteToFile:   It should be made clear in the template that 
*both* the Security policy
   and the file access value are used to check that the file can be 
updated.


200: loadPasswords() - should this confirm the access to the file is 
allowed and it has

the correct file access before reading?

Is the re-writing of the passwords intended to be done by a 
'priveleged' system.

Does this need doPrivileged?

* HashedPasswordFileTest:

88: should use the TestLibrary Utils.getRandomInstance so it logs the 
seed and can be replayed if necessary.



Thanks, Roger


On 4/23/2017 6:20 AM, Harsha Wardhana B wrote:


Hi All,

Please review this enhancement to replace plain-text password for 
JMX agent with SHA-256 hash.


Issue: https://bugs.openjdk.java.net/browse/JDK-5016517
<https://bugs.openjdk.java.net/browse/JDK-5016517>

webrev: http://cr.openjdk.java.net/~hb/5016517/webrev.00/

Overview of implementation:

Currently, the JMX agent password file used to authenticate user, 
stores user name and password as clear text. Though system level 
restrictions are recommended for jmx password file, passwords are 
vulnerable since they are stored in clear. The current RFE proposes 
to store passwords as SHA256 hash instead of clear text.


In current implementation, if password file is writable, and if 
passwords are in clear, they will be replaced by SHA256 hash upon 
agent boot-up or when login attempt is made.


The file, 
src/jdk.management.agent/share/conf/jmxremote.password.template 
contains more details about the implementation.


- Harsha












Re: RFR: JDK-6515161 If remote removeNotificationListener gets SecurityException, client no longer gets notifications

2017-05-07 Thread Harsha Wardhana B

Hi Ujwal,

The fix looks fine.

Some nits.

In ClientNotifForwarder.java, "getListenerIds" could be renamed to 
getClientListenrIds.


-Harsha


On Thursday 04 May 2017 12:29 PM, Ujwal Vangapally wrote:


corrected webrev link : 
http://cr.openjdk.java.net/~uvangapally/webrev/2017/6515161/webrev.00/



On 5/4/2017 12:14 PM, Ujwal Vangapally wrote:


Kindly review the changes made for below bug

Problem description and solution are explained in comments section

https://bugs.openjdk.java.net/browse/JDK-6515161

diff for*ClientNotifForwarder.java *might be a bit confusing as it 
shows the method name


removeNotificationListener is modified to getListenerIds and new 
method removeNotificationListener is introduced.


Actual change is new method getListenerIds is introduced and it is 
called in removeNotificationListener method without


affecting the functionality of removeNotificationListener.

webrev : cr.openjdk.java.net/~uvangapally/webrev/2017/6515161/webrev.00/

Thanks,

Ujwal,







Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-04-27 Thread Harsha Wardhana B

Hi Roger,

Thanks for the detailed review. I will wait for more review comments 
before incorporating the ones below.


-Harsha


On Tuesday 25 April 2017 10:56 PM, Roger Riggs wrote:

Hi Harsha,

Thanks for this important improvement. Comments:


* jmxremote.password.template:
  "Passwords will be hashed by server if they are in clear." Perhaps 
should be more explicit:


   "The jmxremote.passwords file will be re-written by the server to 
replace all plain text passwords with hashed passwords when the file 
is read by the server."


line 35: "Base64 encoded hash"  -> drop the "Base64" in this line 
isn't needed and

make it seems like it should appear as 1 field instead of 2 or 3.

37+: The syntax of the file may be clearer if it includes the complete 
syntax in (line 39) not

just the password/hash fragment.

Line 41:  "W = spaces"; above "tabs" are allowed as a delimiter; it 
would be good to be consistent
and include the usualy white-space characters in the set, be as 
specific as possible.

Is this the same set of whitespace used by Regex '\\s'.

45: "java platform""  ->   "MD5, SDA-1, SHA-256 are supported 
algorithms."


49: be more specific about 'hashing is requested'  how?  Refer to the 
management.properties

  com.sun.management.jmxremote.password.hash value.



51:  "replace hashed" -> "replace *the *hashed"
52: "with clear text or new" -> "with the clear text or the new"
52: "If new password" -> "If the new password"
53: "when new login" -> "when a new login"

60: "User generated" -> "A User generated"

67: Will the file be ignored if it has the wrong permissions. (With a 
logged message)


* management.properties

306: "(Case for true/false ignored)"  - what does this mean; I think 
it can be removed.


307: missing period at the end of the sentence.
309: "in password file" -> "in the password file"


* FileLoginModule.java

102: can this match better the similar name in the 
management.properties if it has the same function:

com.sun.management.jmxremote.password.hash
103: "replaces clear text passwords" -> "replaces each clear text 
password"

104: indent to match previous  enteries.

* JMXPluggableAuthenticator.java

119: There is no need to copy the password to a new local

128: add a space after ","

256 private static final String HASH_PASSWORDS =
257 "jmx.remote.x.password.file.hash";

The name ".hash" part does not clearly communicate that passwords are 
to be hashed.

"hashPasswords" might be more self explanatory.
Also, can this be NOT duplicated here and in ConnectorBootStrap.java?


* ConnectorBootStrap.java:
 482: Add space after ","s; no spaces before.

770: use the same name for the option/property if possible to avoid 
confusion.


770:  if the HASH_PASSWORDS static is appropriate use it instead of 
literal "true".


* HashedPasswordManager

80-83: The fields can be final and use the constructor to initialize 
in all cases and make the class final

to avoid unintentional subclassing.


113: canWriteToFile:   It should be made clear in the template that 
*both* the Security policy
   and the file access value are used to check that the file can be 
updated.


200: loadPasswords() - should this confirm the access to the file is 
allowed and it has

the correct file access before reading?

Is the re-writing of the passwords intended to be done by a 
'priveleged' system.

Does this need doPrivileged?

* HashedPasswordFileTest:

88: should use the TestLibrary Utils.getRandomInstance so it logs the 
seed and can be replayed if necessary.



Thanks, Roger


On 4/23/2017 6:20 AM, Harsha Wardhana B wrote:


Hi All,

Please review this enhancement to replace plain-text password for JMX 
agent with SHA-256 hash.


Issue: https://bugs.openjdk.java.net/browse/JDK-5016517
<https://bugs.openjdk.java.net/browse/JDK-5016517>

webrev: http://cr.openjdk.java.net/~hb/5016517/webrev.00/

Overview of implementation:

Currently, the JMX agent password file used to authenticate user, 
stores user name and password as clear text. Though system level 
restrictions are recommended for jmx password file, passwords are 
vulnerable since they are stored in clear. The current RFE proposes 
to store passwords as SHA256 hash instead of clear text.


In current implementation, if password file is writable, and if 
passwords are in clear, they will be replaced by SHA256 hash upon 
agent boot-up or when login attempt is made.


The file, 
src/jdk.management.agent/share/conf/jmxremote.password.template 
contains more details about the implementation.


- Harsha










Re: RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-04-24 Thread Harsha Wardhana B

Hi Gruss,

Crypt format has additional params (|param|name and its|value|: hash 
complexity parameters, like rounds/iterations count ) which are not 
applicable to current implementation. Also,  hash algorithms shipped 
with JDK are applicable (MD5, SHA1, SHA256) and any other algorithms 
specified by crypt format will be ignored.


Crypt format can be used, but it is over-engineered for current 
requirement/implementation. I am not opposed to using it and would 
welcome input from other reviewers.


-Harsha

On Sunday 23 April 2017 08:10 PM, Bernd Eckenfels wrote:
Hm, why introduce a new password hash format. Just use modular crypt() 
format (and iterations). This allows to use common tools (like 
htpasswd) to generate the hashes. It would use $5$ prefix for SHA256 
but actually I would use $6$ for iterated SHA512 as it is the default 
on most recent Linux distributions.


Gruss
Bernd
--
http://bernd.eckenfels.net

*From:* serviceability-dev 
<serviceability-dev-boun...@openjdk.java.net> on behalf of Harsha 
Wardhana B <harsha.wardhan...@oracle.com>

*Sent:* Sunday, April 23, 2017 12:20:57 PM
*To:* serviceability-dev@openjdk.java.net
*Subject:* RFE Review : JDK-5016517 - Replace plaintext passwords by 
hashed passwords for out-of-the-box JMX Agent


Hi All,

Please review this enhancement to replace plain-text password for JMX 
agent with SHA-256 hash.


Issue: https://bugs.openjdk.java.net/browse/JDK-5016517
<https://bugs.openjdk.java.net/browse/JDK-5016517>

webrev: http://cr.openjdk.java.net/~hb/5016517/webrev.00/

Overview of implementation:

Currently, the JMX agent password file used to authenticate user, 
stores user name and password as clear text. Though system level 
restrictions are recommended for jmx password file, passwords are 
vulnerable since they are stored in clear. The current RFE proposes to 
store passwords as SHA256 hash instead of clear text.


In current implementation, if password file is writable, and if 
passwords are in clear, they will be replaced by SHA256 hash upon 
agent boot-up or when login attempt is made.


The file, 
src/jdk.management.agent/share/conf/jmxremote.password.template 
contains more details about the implementation.


- Harsha








RFE Review : JDK-5016517 - Replace plaintext passwords by hashed passwords for out-of-the-box JMX Agent

2017-04-23 Thread Harsha Wardhana B

Hi All,

Please review this enhancement to replace plain-text password for JMX 
agent with SHA-256 hash.


Issue: https://bugs.openjdk.java.net/browse/JDK-5016517


webrev: http://cr.openjdk.java.net/~hb/5016517/webrev.00/

Overview of implementation:

Currently, the JMX agent password file used to authenticate user, stores 
user name and password as clear text. Though system level restrictions 
are recommended for jmx password file, passwords are vulnerable since 
they are stored in clear. The current RFE proposes to store passwords as 
SHA256 hash instead of clear text.


In current implementation, if password file is writable, and if 
passwords are in clear, they will be replaced by SHA256 hash upon agent 
boot-up or when login attempt is made.


The file, 
src/jdk.management.agent/share/conf/jmxremote.password.template contains 
more details about the implementation.


- Harsha






Re: RFR - [RFE] JDK-8007141 : Introduce Dynamic MBean exposing the perf counters

2017-03-07 Thread Harsha Wardhana B

Hi Daniel,


On Tuesday 07 March 2017 08:40 PM, Daniel Fuchs wrote:

Hi Harsha,

Not a review either (at least not a complete one).

PlatformMBeanProviderImpl:

 281 @Override
 282 public Set<Class> 
mbeanInterfaces() {

 283 return Collections.emptySet();
 284 }

For future maintainers, I think it would be good to copy
the comment at line 250 and insert it before line 283 too:
 250 // DynamicMBean cannot be used to find an 
MBean by ManagementFactory



Will do.

HotSpotPerfCounterMBean:

Exception handling: I have the feeling that this part might
be a bit over-engineered. If you look at javax.management.StandardMBean
(which is a canonical implementation of DynamicMBean) and
then transitively at MBeanSupport and PerInterface where this class
eventually delegates to, you will see that:

1. You can throw NPE in setAttribute when attribute == null (no need for
   all the wrapping)
If attribute == null, isn't it better to throw IllegalArgumentException 
instead of NPE? I'll remove the wrapping.

2. You should throw AttributeNotFoundException when attempting to read
   a write-only attribute or write a read-only attribute
Isn't UnSupportedOperationEx better than AttributeNotFoundException? 
Have we committed to above in the specs?

3. You can throw NPE if AttributeList is null
If attribute == null, isn't it better to throw IllegalArgumentException 
instead of NPE? I'll remove the wrapping.


 179 String typeName = "java.lang.String";

That looks like a hack.
If attribute is null, defaulting to String would be convenient as 
getAttribute can return empty string instead of null. Do you think 
otherwise?


What if at some point the value of that attribute becomes non null,
and its class is *not* java.lang.String?
Then MBeanAttributeInfo would be lying.
If that ever happens - then it would be more consistent to coerce
the value to its declared type (String) before sending it as a
a result for getAttribute.
Since perf-counters are key-value pairs written into shared memory, it 
is reasonable to expect new counters to be added or type of existing 
counters to be updated while VM is running. I have to refresh the 
counters periodically (maybe once every 5 mins) since I will not be 
notified of any change. If any attributes are added or if existing 
attribute types are changed, then AttributeChangeNotification will be 
sent. Clients will have to refresh MBeanInfo upon receiving this 
notification. So yeah, there is a brief window where MBeanInfo will be 
lying. I don't see easy way to fix it unlesss perfcounters can notify 
MBean of any mutations. Maybe the limitation can be documented.


I will make these changes in next webrev.


Or better, find a way to figure out what should be the class name
of the value even if the value is null (isn't there some metadata
available for these perf counters somewhere?).

PerfCounterMBeanTest:

testGetAttribute should verify that class of the returned value
corresponds to what was declared in the MBeanAttributeInfo for the
corresponding attribute.

Sure. Will do.


cheers,

-- daniel

-Harsha


On 26/02/17 16:50, Harsha Wardhana B wrote:

Hi All,

Please review the below RFE,

JDK-8007141 <http://JDK-8007141> : Introduce Dynamic MBean exposing the
perf counters.

with webrev at,

http://cr.openjdk.java.net/~hb/8007141/webrev.00/

Appreciate if I can get inputs for below.

1. Location of HotSpotPerfCounterMBean. It is located at
src/jdk.management/share/classes/com/sun/management/internal. It can be
moved to src/jdk.management/share/classes/com/sun/management if 
required.


2. Javadoc comments for HotSpotPerfCounterMBean. Not sure if it is 
adequate.


3. Description for each attribute of MBean. I am using getUnits(),
getVariability(), and getFlags() for description. I am not sure if that
is the right description. Appreciate inputs from someone who knows perf
counters well.

Thanks

Harsha








Re: RFR - [RFE] JDK-8007141 : Introduce Dynamic MBean exposing the perf counters

2017-02-28 Thread Harsha Wardhana B
xFills --> 67
sun.gc.tlab.maxGcWaste --> 36674
sun.gc.tlab.maxSlowAlloc --> 0
sun.gc.tlab.maxSlowWaste --> 5028
sun.gc.tlab.slowAlloc --> 0
sun.gc.tlab.slowWaste --> 5028
sun.os.hrt.frequency --> 10
sun.os.hrt.ticks --> 6279815676
sun.property.sun.boot.library.path --> 
/home/harsha/work/jdk10_PerfCounter/build/linux-x86_64-normal-server-fastdebug/jdk/lib

sun.rt._sync_ContendedLockAttempts --> 0
sun.rt._sync_Deflations --> 3
sun.rt._sync_EmptyNotifications --> 0
sun.rt._sync_FailedSpins --> 0
sun.rt._sync_FutileWakeups --> 0
sun.rt._sync_Inflations --> 8
sun.rt._sync_MonExtant --> 4
sun.rt._sync_MonInCirculation --> 0
sun.rt._sync_MonScavenged --> 0
sun.rt._sync_Notifications --> 2
sun.rt._sync_Parks --> 2
sun.rt._sync_PrivateA --> 0
sun.rt._sync_PrivateB --> 0
sun.rt._sync_SlowEnter --> 0
sun.rt._sync_SlowExit --> 0
sun.rt._sync_SlowNotify --> 0
sun.rt._sync_SlowNotifyAll --> 0
sun.rt._sync_SuccessfulSpins --> 0
sun.rt.applicationTime --> 4337190130
sun.rt.createVmBeginTime --> 1488277242189
sun.rt.createVmEndTime --> 1488277244988
sun.rt.internalVersion --> Java HotSpot(TM) 64-Bit Server VM 
(fastdebug 10-internal+0-adhoc.harsha.jdk10PerfCounter) for linux-amd64 
JRE (10-internal+0-adhoc.harsha.jdk10PerfCounter), built on Feb 25 2017 
22:24:55 by "harsha" with gcc 5.4.0 20160609
sun.rt.javaCommand --> com.sun.javatest.regtest.agent.MainWrapper 
/home/harsha/work/jdk10_PerfCounter/build/linux-x86_64-normal-server-fastdebug/nb-jtreg/work/java/lang/management/PerfCounterMBeanTest.d/testng.0.jta 
java/lang/management/PerfCounterMBeanTest.java PerfCounterMBeanTest
sun.rt.jvmCapabilities --> 
1100

sun.rt.jvmVersion --> 167772160
sun.rt.safepointSyncTime --> 35150781
sun.rt.safepointTime --> 44606495
sun.rt.safepoints --> 9
sun.rt.vmInitDoneTime --> 1488277242348
sun.threads.vmOperationTime --> 8730462
sun.urlClassLoader.readClassBytesTime --> 0
sun.zip.zipFile.openTime --> 32909964
sun.zip.zipFiles --> 3


On Tuesday 28 February 2017 12:36 PM, David Holmes wrote:

Hi Harsha,

Not a review :)

On 27/02/2017 2:50 AM, Harsha Wardhana B wrote:

Hi All,

Please review the below RFE,

JDK-8007141 <http://JDK-8007141> : Introduce Dynamic MBean exposing the
perf counters.


What perf counters are these and where/how are they currently documented?

They may be affected by the UsePerfData VM flag (which some/most of 
the management code seems to be ignorant of).


Thanks,
David
-


with webrev at,

http://cr.openjdk.java.net/~hb/8007141/webrev.00/

Appreciate if I can get inputs for below.

1. Location of HotSpotPerfCounterMBean. It is located at
src/jdk.management/share/classes/com/sun/management/internal. It can be
moved to src/jdk.management/share/classes/com/sun/management if 
required.


2. Javadoc comments for HotSpotPerfCounterMBean. Not sure if it is 
adequate.


3. Description for each attribute of MBean. I am using getUnits(),
getVariability(), and getFlags() for description. I am not sure if that
is the right description. Appreciate inputs from someone who knows perf
counters well.

Thanks

Harsha






Re: RFR - [RFE] JDK-8007141 : Introduce Dynamic MBean exposing the perf counters

2017-02-27 Thread Harsha Wardhana B
Perfcounter are dynamic and can change. Applications must be aware of 
that and work around it.


Perf counters being dynamic must be documented and must not be a 
deterrent for consuming them (via Dymanic MBean).


Regards

Harsha


On Monday 27 February 2017 11:22 PM, Erik Gahlin wrote:
If somebody writes a tool that plots the values that the perf counters 
provide, which is bound to happen if it is exposed via JMX, but then 
the internals of the JVM is changed and the perf counter value is 
removed or it is incorrect.


Erik


Hi Erik,

I am not sure if Perf Counters could be disabled. If yes, then 
PerfCounter MBean must throw appropriate exception while getting 
MBeanInfo.


I don't know about tests for PerfCounter. The webrev contains tests 
for PerfCounter MBean.


I am not sure how we will be breaking other's code. Could you please 
elaborate?


Thanks
Harsha

On Monday 27 February 2017 07:39 PM, Erik Gahlin wrote:

Hi Harsha,

How will perf counters be supported?

Can they be removed at anytime, or only at major releases etc. Do we 
have tests for them? I think it would be good know, and perhaps 
state somewhere so we don't break people's code.


Erik


Hi All,

Please review the below RFE,

JDK-8007141  : Introduce Dynamic MBean exposing 
the perf counters.


with webrev at,

http://cr.openjdk.java.net/~hb/8007141/webrev.00/

Appreciate if I can get inputs for below.

1. Location of HotSpotPerfCounterMBean. It is located at 
src/jdk.management/share/classes/com/sun/management/internal. It 
can be moved to src/jdk.management/share/classes/com/sun/management 
if required.


2. Javadoc comments for HotSpotPerfCounterMBean. Not sure if it is 
adequate.


3. Description for each attribute of MBean. I am using getUnits(), 
getVariability(), and getFlags() for description. I am not sure if 
that is the right description. Appreciate inputs from someone who 
knows perf counters well.


Thanks

Harsha












Re: RFR - [RFE] JDK-8007141 : Introduce Dynamic MBean exposing the perf counters

2017-02-27 Thread Harsha Wardhana B

Hi Erik,

I am not sure if Perf Counters could be disabled. If yes, then 
PerfCounter MBean must throw appropriate exception while getting MBeanInfo.


I don't know about tests for PerfCounter. The webrev contains tests for 
PerfCounter MBean.


I am not sure how we will be breaking other's code. Could you please 
elaborate?


Thanks
Harsha

On Monday 27 February 2017 07:39 PM, Erik Gahlin wrote:

Hi Harsha,

How will perf counters be supported?

Can they be removed at anytime, or only at major releases etc. Do we 
have tests for them? I think it would be good know, and perhaps state 
somewhere so we don't break people's code.


Erik


Hi All,

Please review the below RFE,

JDK-8007141  : Introduce Dynamic MBean exposing 
the perf counters.


with webrev at,

http://cr.openjdk.java.net/~hb/8007141/webrev.00/

Appreciate if I can get inputs for below.

1. Location of HotSpotPerfCounterMBean. It is located at 
src/jdk.management/share/classes/com/sun/management/internal. It can 
be moved to src/jdk.management/share/classes/com/sun/management if 
required.


2. Javadoc comments for HotSpotPerfCounterMBean. Not sure if it is 
adequate.


3. Description for each attribute of MBean. I am using getUnits(), 
getVariability(), and getFlags() for description. I am not sure if 
that is the right description. Appreciate inputs from someone who 
knows perf counters well.


Thanks

Harsha








RFR - [RFE] JDK-8007141 : Introduce Dynamic MBean exposing the perf counters

2017-02-26 Thread Harsha Wardhana B

Hi All,

Please review the below RFE,

JDK-8007141  : Introduce Dynamic MBean exposing the 
perf counters.


with webrev at,

http://cr.openjdk.java.net/~hb/8007141/webrev.00/

Appreciate if I can get inputs for below.

1. Location of HotSpotPerfCounterMBean. It is located at 
src/jdk.management/share/classes/com/sun/management/internal. It can be 
moved to src/jdk.management/share/classes/com/sun/management if required.


2. Javadoc comments for HotSpotPerfCounterMBean. Not sure if it is adequate.

3. Description for each attribute of MBean. I am using getUnits(), 
getVariability(), and getFlags() for description. I am not sure if that 
is the right description. Appreciate inputs from someone who knows perf 
counters well.


Thanks

Harsha




Re: RFR : JDK-7132577 - javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22

2017-02-23 Thread Harsha Wardhana B

Looks good.

-Harsha


On Thursday 23 February 2017 12:28 PM, Amit Sapre wrote:

Hello,

http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-7132577/webrev.02/ has the 
updated changes.

I ran this test on my VM and roughly takes 250-300 ms to get all the listener 
count.

Thanks,
Amit


-Original Message-
From: Amit Sapre
Sent: Thursday, February 23, 2017 11:55 AM
To: David Holmes; serviceability-dev@openjdk.java.net; Harsha Wardhana
B
Subject: RE: RFR : JDK-7132577 -
javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22

Hello,

In a messy run of this test case,
the number of prints for the counter values will be 240 (120 seconds is
jtreg timeout)

Will try to optimize this. Please hold on for a new webrev.

Thanks,
Amit



-Original Message-
From: Amit Sapre
Sent: Thursday, February 23, 2017 11:48 AM
To: David Holmes; serviceability-dev@openjdk.java.net; Harsha

Wardhana

B
Subject: RE: RFR : JDK-7132577 -
javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22

Hello,

Thanks David & Harsha for your inputs.
Here is the new webrev :
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-7132577/webrev.01/

Thanks,
Amit


-Original Message-
From: David Holmes
Sent: Thursday, February 23, 2017 9:24 AM
To: serviceability-dev@openjdk.java.net; Sapre Amit
Cc: Harsha Wardhana B
Subject: Re: RFR : JDK-7132577 -
javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22

Hi Amit,

On 23/02/2017 12:18 AM, Harsha Wardhana B wrote:

Hi Amit,

There is no need to wait in a loop to check we have not received

any

notifications. Without starting the monitors, the listener count
will be zero.

The first part of diff L116-L121 could be left as is.

Agreed.


By relying on Jtreg timeout for receiving notifications, we will
be unable to print the number of listeners emitted by each

Monitor.

But

I

guess there is no way to intercept a Jtreg timeout and print out

those

values.

You could print out the values every 1 second, or 5 or 10, ... at
least that way we can see what the values are when we timeout, and
also if they have been changing.

Thanks,
David


Regards

Harsha


On Wednesday 22 February 2017 03:29 PM, Amit Sapre wrote:

Hello,



Please review this test bug fix which eliminates test case's own
timeout mechanism to default jtreg timeout.



Bug ID : https://bugs.openjdk.java.net/browse/JDK-7132577

Webrev :
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-

7132577/webrev.00/

<http://cr.openjdk.java.net/%7Easapre/webrev/2017/JDK-

7132577/webrev.

00/>



Thanks,

Amit





Re: RFR: JDK-8173130 - SubjectDelegation2Test.java and SubjectDelegation3Test.java failing on solaris

2017-02-22 Thread Harsha Wardhana B

Thanks for the review Daniel.

-Harsha


On Wednesday 22 February 2017 08:21 PM, Daniel Fuchs wrote:

Hi Harsha,

OK - makes sense to me.
Maybe just wait for tomorrow to see if you get any other comments
form other reviewers...

best regards,

-- daniel

On 22/02/17 14:38, Harsha Wardhana B wrote:

Hi Daniel,

("java.lang.RuntimePermission" "accessClassInPackage.sun.security.krb5")
was missing.

I gave all the RuntimePermissions since we don't want test cases to fail
in future.

Granting java.lang.RuntimePermission "*" does not affect the test cases
in anyway as test cases rely on delegation of specific permissions.

Regards
Harsha

On Wednesday 22 February 2017 07:43 PM, Daniel Fuchs wrote:

Hi Harsha,

Looks good - but do you really need java.lang.RuntimePermission "*" ?

What permission was missing?

best regards,

-- daniel

On 22/02/17 13:35, Harsha Wardhana B wrote:

Hi All,

Please review the below test fix for

Issue: JDK-8173130 <http://JDK-8173130> - SubjectDelegation2Test.java
and SubjectDelegation3Test.java failing on solaris

webrev : http://cr.openjdk.java.net/~hb/8173130/webrev.00/

The fix does the following.

1. Removes explicit platform check

2. Fixes JMXServiceURL

3. Adds required RuntimePermissions for test to execute.

Regards

Harsha











Re: RFR: JDK-8173130 - SubjectDelegation2Test.java and SubjectDelegation3Test.java failing on solaris

2017-02-22 Thread Harsha Wardhana B

Hi Daniel,

("java.lang.RuntimePermission" "accessClassInPackage.sun.security.krb5") 
was missing.


I gave all the RuntimePermissions since we don't want test cases to fail 
in future.


Granting java.lang.RuntimePermission "*" does not affect the test cases 
in anyway as test cases rely on delegation of specific permissions.


Regards
Harsha

On Wednesday 22 February 2017 07:43 PM, Daniel Fuchs wrote:

Hi Harsha,

Looks good - but do you really need java.lang.RuntimePermission "*" ?

What permission was missing?

best regards,

-- daniel

On 22/02/17 13:35, Harsha Wardhana B wrote:

Hi All,

Please review the below test fix for

Issue: JDK-8173130 <http://JDK-8173130> - SubjectDelegation2Test.java
and SubjectDelegation3Test.java failing on solaris

webrev : http://cr.openjdk.java.net/~hb/8173130/webrev.00/

The fix does the following.

1. Removes explicit platform check

2. Fixes JMXServiceURL

3. Adds required RuntimePermissions for test to execute.

Regards

Harsha







Re: RFR : JDK-7132577 - javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22

2017-02-22 Thread Harsha Wardhana B

Hi Amit,

There is no need to wait in a loop to check we have not received any 
notifications. Without starting the monitors, the listener count will be 
zero.


The first part of diff L116-L121 could be left as is.

By relying on Jtreg timeout for receiving notifications, we will be 
unable to print the number of listeners emitted by each Monitor. But I 
guess there is no way to intercept a Jtreg timeout and print out those 
values.


Regards

Harsha


On Wednesday 22 February 2017 03:29 PM, Amit Sapre wrote:


Hello,

Please review this test bug fix which eliminates test case’s own 
 timeout mechanism to default jtreg timeout.


Bug ID : https://bugs.openjdk.java.net/browse/JDK-7132577

Webrev : 
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-7132577/webrev.00/ 



Thanks,

Amit





RFR: JDK-8173130 - SubjectDelegation2Test.java and SubjectDelegation3Test.java failing on solaris

2017-02-22 Thread Harsha Wardhana B

Hi All,

Please review the below test fix for

Issue: JDK-8173130  - SubjectDelegation2Test.java 
and SubjectDelegation3Test.java failing on solaris


webrev : http://cr.openjdk.java.net/~hb/8173130/webrev.00/

The fix does the following.

1. Removes explicit platform check

2. Fixes JMXServiceURL

3. Adds required RuntimePermissions for test to execute.

Regards

Harsha



Re: RFR : JDK-8167337 - When jmxremote.port=0, JDP broadcasts "0" instead of assigned port

2017-01-17 Thread Harsha Wardhana B

Hi Roger,

Your approach is more elegant. However checking for ":0/" may not work 
as we can have non-zero port number that can end in 0.


Regards

Harsha


On Tuesday 17 January 2017 09:39 PM, Roger Riggs wrote:

Hi Harsha,

On 1/16/2017 1:21 AM, Harsha Wardhana B wrote:

Hi Amit,

In JdpJmxRemoteDynamicPortTestCase:48 needs null/empty check for jmx 
url.


JdpJmxRemoteDynamicPortTestCase:49, array length needs to checked 
before accessing index at token[6].


It is possible that port number need not always be present at given 
index and hence we may have to follow different approach to extract 
port number. Please check if approach below works.




int idx = jmxurl.indexOf(':');
while (idx != -1) {
jmxurl = jmxurl.substring(idx+1);
idx = jmxurl.indexOf(':');
}
This loop would very eagerly find the last ":" in the string even it 
was well past the host/port field.

String.lastIndex would be equivalent.


if(jmxurl.indexOf('/') == -1) {
throw new RuntimeException("Test failed : Invalid 
JMXServiceURL");

}
It would be more efficient to compare the index of the '/' after the 
last ":" than to re-create new substrings.

int colon = jmxurl.lastIndexOf(':');
int slash = jmxurl.indexOf('/', colon);
int port = Integer.parseInt(jmxurl, colon + 1, slash, 10);



String portStr = jmxurl.substring(0,jmxurl.indexOf('/'));
int port = Integer.parseInt(portStr);
if( port == 0 ) {
throw new RuntimeException("Test failed : Zero port for 
jmxremote");

}

Or It might be just as effective to just to check if ":0/" is present.
if (jmxurl.contains(":0/")) {...}

$.02, Roger






Regards

Harsha


On Monday 16 January 2017 11:16 AM, Amit Sapre wrote:

Thanks Dmitry for the review.

Can I have one more reviewer for this fix ?

Thanks,
Amit


-Original Message-
From: Dmitry Samersoff
Sent: Sunday, January 15, 2017 4:49 PM
To: Amit Sapre; serviceability-dev
Subject: Re: RFR : JDK-8167337 - When jmxremote.port=0, JDP broadcasts
"0" instead of assigned port

Amit,

Changes looks good to me.

-Dmitry


On 2017-01-13 09:17, Amit Sapre wrote:

Hello,



Please review the fix for JDK-8167337



Bug Id : https://bugs.openjdk.java.net/browse/JDK-8167337

Webrev :
http://cr.openjdk.java.net/~asapre/webrev/2017/JDK-8167337/webrev.00/



Thanks,

Amit



--
Dmitry Samersoff
Oracle Java development team, Saint Petersburg, Russia
* I would love to change the world, but they won't give me the 
sources.








Re: RFR : JDK-8024352 - MBeanOperationInfo accepts any int value as "impact"

2017-01-17 Thread harsha . wardhana . b


Looks fine. 




On Fri, Jan 13, 2017 at 1:56 PM +0530, "Ujwal Vangapally" 
 wrote:










kindly review the fix for bug JDK-8024352

Bug Id : https://bugs.openjdk.java.net/browse/JDK-8024352

webrev : 
http://cr.openjdk.java.net/~asapre/sponsorships/Ujwal/JDK-8024352/webrev.00/

Thanks,

Ujwal.









Re: RFR - 8169575: com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java failing with jtreg tip

2016-11-18 Thread Harsha Wardhana B

Hello,

Please review below webrev incorporating Roger's comment.

http://cr.openjdk.java.net/~hb/8169575/webrev.01/

-Harsha


On Friday 18 November 2016 09:08 PM, Frederic Parain wrote:

"exitVM.*" should be fine to avoid future maintenance burden.
Thank you for pointing this out Roger.

Fred

On 11/18/2016 10:32 AM, Harsha Wardhana B wrote:

Hi Roger,

I was not sure about adding exitVM.* as that would give permissions for
all exit codes.

Maybe Fred can comment since he is the test case author.

-Harsha


On Friday 18 November 2016 08:58 PM, Roger Riggs wrote:

Hi Harsha,

The addition of the permission for
"getProperty.jdk.jar.disabledAlgorithms" is fine.

But the addition of a permission for exitVM.95 to satisfy the need of
the test harness to exit cleanly
should instead be fixed by changing the "exitVM.97" to "exitVM.*" to
avoid future maintenance
in the case where the test harness changes its exit status.

Roger


On 11/18/2016 4:47 AM, Harsha Wardhana B wrote:

Hello All,

Please review below fix for issue

https://bugs.openjdk.java.net/browse/JDK-8169575

having webrev at,

http://cr.openjdk.java.net/~hb/8169575/webrev.00/

Regards

Harsha









Re: RFR - 8169575: com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java failing with jtreg tip

2016-11-18 Thread Harsha Wardhana B

Hi Roger,

I was not sure about adding exitVM.* as that would give permissions for 
all exit codes.


Maybe Fred can comment since he is the test case author.

-Harsha


On Friday 18 November 2016 08:58 PM, Roger Riggs wrote:

Hi Harsha,

The addition of the permission for 
"getProperty.jdk.jar.disabledAlgorithms" is fine.


But the addition of a permission for exitVM.95 to satisfy the need of 
the test harness to exit cleanly
should instead be fixed by changing the "exitVM.97" to "exitVM.*" to 
avoid future maintenance

in the case where the test harness changes its exit status.

Roger


On 11/18/2016 4:47 AM, Harsha Wardhana B wrote:

Hello All,

Please review below fix for issue

https://bugs.openjdk.java.net/browse/JDK-8169575

having webrev at,

http://cr.openjdk.java.net/~hb/8169575/webrev.00/

Regards

Harsha







RFR - 8169575: com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java failing with jtreg tip

2016-11-18 Thread Harsha Wardhana B

Hello All,

Please review below fix for issue

https://bugs.openjdk.java.net/browse/JDK-8169575

having webrev at,

http://cr.openjdk.java.net/~hb/8169575/webrev.00/

Regards

Harsha



Re: RFR : JDK-8141591 - javax/management/remote/mandatory/threads/ExecutorTest.java fails intermittently

2016-11-15 Thread Harsha Wardhana B

Hello,

Please review below webrev incorporating Daniel's comments.

http://cr.openjdk.java.net/~hb/8141591/webrev.01/

Regards
Harsha

On Monday 14 November 2016 04:14 PM, Daniel Fuchs wrote:

On 14/11/16 06:57, Harsha Wardhana B wrote:

Well, that will not cover the case where user shuts down executor but
keeps the client/server alive. So we will need a executor that can 
keep
notif system running as well as do clean-up if client/server is 
closed.


It's OK to continue in order to do clean up and
shutdown gracefully. It seems wrong to keep going afterwards
as if nothing had happened though (in the case the
user shuts the supplied executor down).

With current changes, we do continue to carry on with linear executor.
If the user wants to shutdown the system, he can always do it by
shutting down client and server along with executor. If he shuts down
executor but not client/server, it may be safe to assume that he wants
the system to be up and running. It may not be appropriate to assume
user wants to shutdown notif system just because he shutdown executor.


Well, it may also not be appropriate to invoke a user provided callback
on another executor than the one provided by the user.
If the user provides an executor, we must assume he has good
reasons to do so.
I'm not hard set to opposing to what you propose, but it makes me
feel uncomfortable.

best regards,

-- daniel




Re: RFR : JDK-8141591 - javax/management/remote/mandatory/threads/ExecutorTest.java fails intermittently

2016-11-13 Thread Harsha Wardhana B

Hi Daniel,

On Friday 11 November 2016 11:02 PM, Daniel Fuchs wrote:

On 11/11/16 16:57, Harsha Wardhana B wrote:

Hi Daniel,
Old executor will be shutdown by the user. We are only swapping a user
supplied executor with new linear executor. It will follow the same
shutdown sequence as original one.


OK - the LinearExecutor has only one thread and that thread
will terminate gracefully when there is nothing more to
fetch - so shutdown of the new executor will not be an issue.


I wonder whether you should instead perform the cleaning
action directly in the catch clause - that is - copy
the lines 553-562 over there, or maybe simply
call this::doRun() - without submitting 'this'
to an executor... But then we would have to have
some guarantee that doRun() will terminate and
not call doRun() again (hence my suggestion to
copy lines 553-562 instead)...

Well, that will not cover the case where user shuts down executor but
keeps the client/server alive. So we will need a executor that can keep
notif system running as well as do clean-up if client/server is closed.


It's OK to continue in order to do clean up and
shutdown gracefully. It seems wrong to keep going afterwards
as if nothing had happened though (in the case the
user shuts the supplied executor down).
With current changes, we do continue to carry on with linear executor. 
If the user wants to shutdown the system, he can always do it by 
shutting down client and server along with executor. If he shuts down 
executor but not client/server, it may be safe to assume that he wants 
the system to be up and running. It may not be appropriate to assume 
user wants to shutdown notif system just because he shutdown executor.



This code is very hairy - with states and multiple
critical sections and wait() and notifyAll(), so it
is difficult to reason about, and I can't guarantee
that it would be the right thing to do...
But maybe it would be worth prototyping it and see if
it also passes all the non-reg tests?


Yes Daniel. It is a precarious section of code loosely held together by
states. However, I think the changes are not too intrusive since it does
not rely on states. It only looks for RejectedExecutionException. I have
written test-case that can validate my changes. I haven't JPRT yet but
would be happy to share test results if required.


If executor is no longer final then it should be volatile.
And you should use double locking when resetting its value:

   if (!(executor  instanceof LinearExecutor)) {
   synchronized (ClientNotifForwarder.this) {
   if (!(executor  instanceof LinearExecutor)) {
executor = new LinearExecutor();
   }
   }
   executor.submit(this);
   }



Sure. Will send the updated webrev.


-- daniel


best regards,

-- daniel

On 11/11/16 16:02, Harsha Wardhana B wrote:

Hello,

Please review the fix for

issue : https://bugs.openjdk.java.net/browse/JDK-8141591

webrev : http://cr.openjdk.java.net/~hb/8141591/webrev.00/

Fix details:

The root-cause for the issue is that NotifFetcher thread was 
suspended

at L562 after which main thread ran to completion shutting down both
client and server and stopping the executor. Fixing as

synchronized (ClientNotifForwarder.this) {
 if (state == STARTED) {
executor.execute(new NotifFetcher());
 }
  }

will not solve the problem since NotifFetcher can get suspended after
checking state==STARTED and still hit the same problem.

One way to solve would be to catch RejectedExecutionException and 
then

fallback on linearExecutor. This will take care of necessary cleanup
if client/server are shutdown or keeps the system running if executor
is abrupty shutdown by the client without stopping the client/server.


The comments section of the issue also has discussion about various 
ways
of fixing the issue and merits/demerits of different approaches. It 
also

helps in getting a perspective on issue and the fix.

Thanks

Harsha




Thanks
Harsha



-Harsha


Re: RFR : JDK-8141591 - javax/management/remote/mandatory/threads/ExecutorTest.java fails intermittently

2016-11-11 Thread Harsha Wardhana B

Hi Daniel,


On Friday 11 November 2016 10:12 PM, Daniel Fuchs wrote:

Hi Harsha,

 // We reached here because the executor was shutdown.
 // If executor was supplied by client, then it was shutdown
 // abruptly or JMXConnector was shutdown along with executor
 // while this thread was suspended at L564.
 if (!(executor instanceof LinearExecutor)) {
 // Spawn new executor that will do cleanup if JMXConnector is closed
 // or keep notif system running otherwise
 executor = new LinearExecutor();


I find it a bit strange to 'keep notif system running' if
the executor was shutdown.

It may happen that user will not be aware of shutdown sequence 
(client->server->executor) and may shutdown executor first. In that 
case, we may need to keep notif system running.

If the user that supplied the executor shuts it down,
then does it make sense to continue running? Also
if the old executor has already been shutdown - and you
create a new one - then do we have any guarantee that
the new executor will be shut down properly?
Old executor will be shutdown by the user. We are only swapping a user 
supplied executor with new linear executor. It will follow the same 
shutdown sequence as original one.


I wonder whether you should instead perform the cleaning
action directly in the catch clause - that is - copy
the lines 553-562 over there, or maybe simply
call this::doRun() - without submitting 'this'
to an executor... But then we would have to have
some guarantee that doRun() will terminate and
not call doRun() again (hence my suggestion to
copy lines 553-562 instead)...
Well, that will not cover the case where user shuts down executor but 
keeps the client/server alive. So we will need a executor that can keep 
notif system running as well as do clean-up if client/server is closed.


This code is very hairy - with states and multiple
critical sections and wait() and notifyAll(), so it
is difficult to reason about, and I can't guarantee
that it would be the right thing to do...
But maybe it would be worth prototyping it and see if
it also passes all the non-reg tests?

Yes Daniel. It is a precarious section of code loosely held together by 
states. However, I think the changes are not too intrusive since it does 
not rely on states. It only looks for RejectedExecutionException. I have 
written test-case that can validate my changes. I haven't JPRT yet but 
would be happy to share test results if required.

best regards,

-- daniel

On 11/11/16 16:02, Harsha Wardhana B wrote:

Hello,

Please review the fix for

issue : https://bugs.openjdk.java.net/browse/JDK-8141591

webrev : http://cr.openjdk.java.net/~hb/8141591/webrev.00/

Fix details:


The root-cause for the issue is that NotifFetcher thread was suspended
at L562 after which main thread ran to completion shutting down both
client and server and stopping the executor. Fixing as

synchronized (ClientNotifForwarder.this) {
 if (state == STARTED) {
executor.execute(new NotifFetcher());
 }
  }

will not solve the problem since NotifFetcher can get suspended after
checking state==STARTED and still hit the same problem.

One way to solve would be to catch RejectedExecutionException and then
fallback on linearExecutor. This will take care of necessary cleanup
if client/server are shutdown or keeps the system running if executor
is abrupty shutdown by the client without stopping the client/server.


The comments section of the issue also has discussion about various ways
of fixing the issue and merits/demerits of different approaches. It also
helps in getting a perspective on issue and the fix.

Thanks

Harsha




Thanks
Harsha


RFR : JDK-8141591 - javax/management/remote/mandatory/threads/ExecutorTest.java fails intermittently

2016-11-11 Thread Harsha Wardhana B

Hello,

Please review the fix for

issue : https://bugs.openjdk.java.net/browse/JDK-8141591

webrev : http://cr.openjdk.java.net/~hb/8141591/webrev.00/

Fix details:

The root-cause for the issue is that NotifFetcher thread was suspended 
at L562 after which main thread ran to completion shutting down both 
client and server and stopping the executor. Fixing as


synchronized (ClientNotifForwarder.this) {
 if (state == STARTED) {
executor.execute(new NotifFetcher());
 }
  }

will not solve the problem since NotifFetcher can get suspended after 
checking state==STARTED and still hit the same problem.


One way to solve would be to catch RejectedExecutionException and then 
fallback on linearExecutor. This will take care of necessary cleanup 
if client/server are shutdown or keeps the system running if executor 
is abrupty shutdown by the client without stopping the client/server.


The comments section of the issue also has discussion about various ways 
of fixing the issue and merits/demerits of different approaches. It also 
helps in getting a perspective on issue and the fix.


Thanks

Harsha



Re: RFR: JDK-8168141: javax/management/remote/mandatory/notif/EmptyDomainNotificationTest.java: No notif received!

2016-11-07 Thread Harsha Wardhana B

Looks good.

-Harsha


On Monday 07 November 2016 09:08 PM, Ujwal Vangapally wrote:

Gentle remainder

Thanks,

Ujwal.


On 11/4/2016 4:33 PM, Ujwal Vangapally wrote:

Please review this small change for the bug below

https://bugs.openjdk.java.net/browse/JDK-8168141

Webrev: 
http://cr.openjdk.java.net/~asapre/sponsorships/Ujwal/JDK-8168141/webrev.01/


Thanks,
Ujwal.






Re: RFR: JDK-8068155: [Findbugs]new sun.jvm.hotspot.utilities.ObjectReader() creates a sun.jvm.hotspot.utilities.ProcImageClassLoader classloader, which should be performed within a doPrivileged block

2016-09-15 Thread Harsha wardhana B

Hello,

It is not required that SA should be run under security manager to 
address this change. Any standalone application when run under security 
manager can use ObjectReader class to exploit vulnerabilities. That is 
something that should be evaluated.


With the below fix any application when run under security manager 
without RuntimePermission.createClassLoader will be able to create 
ProcImageClassLoader. We need to check if it is something that is 
desired and what vulnerabilities can be exploited, if any.


-Harsha

On 9/14/2016 5:58 PM, Sharath Ballal wrote:

David,

That aside, the code uses raw types, which is bad. It should also be able to 
retain the this(...) invocation e.g (I haven't compiled this):

This works, Thanks.


-Sharath Ballal



-Original Message-
From: David Holmes
Sent: Wednesday, September 14, 2016 3:07 PM
To: Sharath Ballal;serviceability-dev@openjdk.java.net
Subject: Re: RFR: JDK-8068155: [Findbugs]new 
sun.jvm.hotspot.utilities.ObjectReader() creates a 
sun.jvm.hotspot.utilities.ProcImageClassLoader classloader, which should be 
performed within a doPrivileged block

Hi Sharath,

On 14/09/2016 6:14 PM, Sharath Ballal wrote:

Hello,

Please review this fix to add creation of classloader code into
doPrivileged block

Issue:https://bugs.openjdk.java.net/browse/JDK-8068155

Webrev:http://cr.openjdk.java.net/~sballal/8068155/webrev.00/

First I'm also curious about why FindBugs thinks this is needed. AFAIK you use 
the doPrivileged to allow you to create the classLoader when it would otherwise 
fail if a SecurityManager were present.

That aside, the code uses raw types, which is bad. It should also be able to 
retain the this(...) invocation e.g (I haven't compiled this):

public ObjectReader() {
this(AccessController.doPrivileged(
   new PrivilegedAction() {
  public ClassLoader run() {
 return new ProcImageClassLoader();
  }
   }
));
 }

Thanks,
David


-Sharath Ballal









Re: RFR: 8161448: 4 JNI exception pending defect groups in DiagnosticCommandImpl.c

2016-09-06 Thread Harsha Wardhana B

Thanks for the review, Dmitry.

Harsha


On Tuesday 06 September 2016 12:27 PM, Dmitry Samersoff wrote:

Harsha,

OK. The fix looks good for me.

-Dmitry

On 2016-09-06 09:49, Harsha Wardhana B wrote:

Dmitry,

The scope of the issue was to fix parfait warnings though I have gone to
some extent to refactor the file.

Agree that macro can be used, but we have to stop here and raise a new
issue to carry-on with the refactoring process.

Thanks

Harsha

On Tuesday 06 September 2016 12:03 PM, Dmitry Samersoff wrote:

Harsha,

EXCEPTION_CHECK_AND_FREE macro could be used at ll.76 after FindClass

-Dmitry

On 2016-09-06 08:47, Harsha Wardhana B wrote:

Hi David,

Please find revised webrev.

http://cr.openjdk.java.net/~hb/8161448/webrev.03/

-Harsha

On Thursday 01 September 2016 03:31 PM, David Holmes wrote:

On 1/09/2016 6:05 PM, Harsha Wardhana B wrote:

Hi David,

On Thursday 01 September 2016 01:14 PM, David Holmes wrote:

Hi Harsha,

Sorry these style issues are proving to be so painful, normally there
would be more direct guidance from an existing team member.

On 30/08/2016 4:51 PM, Harsha Wardhana B wrote:

Hello,

Please find below webrev addressing David's and Dmitry's comments.

http://cr.openjdk.java.net/~hb/8161448/webrev.02/

The idiomatic way we write such macros is as follows:

#define EXCEPTION_CHECK_AND_FREE(x) \
do { \
  if ((*env)->ExceptionCheck(env)) { \
 free(x); \
 return NULL; \
  } \
} while (false)

I am aware of this style but I wasn't aware what style should be used
(BTW last line should be 'while(0)'). I didn't want to do anything
fancy
and end up sending one more webrev and hence I followed the
simplest way
to write a multi-line macro.
Now if there isn't anything wrong, I think we should leave it as is
until coding guidelines are put in place. I am facing same problem in
another issue where I have sent multiple webrev fixing only nits.
It is
turning out to be very painful.

I understand and it is unfortunate that there has not been more
definitive guidance here. But it is better to adopt established style
and get used to using it. If you form is left in then you need spaces
before trailing \ - another style nit, sorry.


---

   109 if (obj == NULL) {
   110 EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
   111 }

Checking both NULL and for exceptions is redundant as previously
pointed out. Either leave this code as it was:

Yes. it may be redundant but it is harmless. Does this really need
to be
changed?

Yes it breeds confusion to see multiple checks that are unnecessary
(and we're trying to address this with a lot of the JNI using code in
the VM at the moment). In this case it is even worse because without
knowing the exception check must be true and so "return NULL" will
always execute, this code has the appearance of being able to continue
if obj == NULL!

Sorry. And thanks.

David
-


91 if (obj == NULL) {
92   free(dcmd_arg_info_array);
93   return NULL;
94 }

or else just replace it with:

109EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

The same for the block here:

   201   if (obj == NULL){
   202 EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
   203   }


Thanks,
David
-


-Harsha

On Tuesday 30 August 2016 09:46 AM, David Holmes wrote:

On 30/08/2016 2:06 PM, Harsha Wardhana B wrote:

Error checking might distract the main flow of code but it
would be
far-fetched to call that it obfuscates the code. Ideally error
checking

You claimed macros obfuscate so the same word seemed appropriate. I
don't necessarily equate readability with obfuscation.


could have been made a function (inline if possible) instead of a
macro
but since it is context sensitive in this case (have to free
variables
depending on context) , doing so would obfuscate the code even
more.

I tried to separate it into a function and the code looks more
uglier.

I was envisaging something like:

jstring jname, jdesc,jtype,jdefStr;
jname =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].name);
EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
jdesc =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].description);
EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
jtype =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].type);
EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
jdefStr = (*env)->NewStringUTF(env,
dcmd_arg_info_array[i].default_string);
EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

Of course if this were C++ code instead of C there would be better
techniques for dealing with the free'ing.

Cheers,
David



-Harsha
On Tuesday 30 August 2016 09:26 AM, David Holmes wrote:

On 30/08/2016 1:47 PM, Harsha Wardhana B wrote:

Hi Dmitry,

I am not sure how using macro will help in this context. As far
as I
know, macros must be sparingly used as they are error-prone,
obfuscate
the code and hard to debug. Most of bes

Re: RFR: 8161448: 4 JNI exception pending defect groups in DiagnosticCommandImpl.c

2016-09-06 Thread Harsha Wardhana B

Dmitry,

The scope of the issue was to fix parfait warnings though I have gone to 
some extent to refactor the file.


Agree that macro can be used, but we have to stop here and raise a new 
issue to carry-on with the refactoring process.


Thanks

Harsha

On Tuesday 06 September 2016 12:03 PM, Dmitry Samersoff wrote:

Harsha,

EXCEPTION_CHECK_AND_FREE macro could be used at ll.76 after FindClass

-Dmitry

On 2016-09-06 08:47, Harsha Wardhana B wrote:

Hi David,

Please find revised webrev.

http://cr.openjdk.java.net/~hb/8161448/webrev.03/

-Harsha

On Thursday 01 September 2016 03:31 PM, David Holmes wrote:

On 1/09/2016 6:05 PM, Harsha Wardhana B wrote:

Hi David,

On Thursday 01 September 2016 01:14 PM, David Holmes wrote:

Hi Harsha,

Sorry these style issues are proving to be so painful, normally there
would be more direct guidance from an existing team member.

On 30/08/2016 4:51 PM, Harsha Wardhana B wrote:

Hello,

Please find below webrev addressing David's and Dmitry's comments.

http://cr.openjdk.java.net/~hb/8161448/webrev.02/

The idiomatic way we write such macros is as follows:

#define EXCEPTION_CHECK_AND_FREE(x) \
   do { \
 if ((*env)->ExceptionCheck(env)) { \
free(x); \
return NULL; \
 } \
   } while (false)

I am aware of this style but I wasn't aware what style should be used
(BTW last line should be 'while(0)'). I didn't want to do anything fancy
and end up sending one more webrev and hence I followed the simplest way
to write a multi-line macro.
Now if there isn't anything wrong, I think we should leave it as is
until coding guidelines are put in place. I am facing same problem in
another issue where I have sent multiple webrev fixing only nits. It is
turning out to be very painful.

I understand and it is unfortunate that there has not been more
definitive guidance here. But it is better to adopt established style
and get used to using it. If you form is left in then you need spaces
before trailing \ - another style nit, sorry.


---

  109 if (obj == NULL) {
  110 EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  111 }

Checking both NULL and for exceptions is redundant as previously
pointed out. Either leave this code as it was:

Yes. it may be redundant but it is harmless. Does this really need to be
changed?

Yes it breeds confusion to see multiple checks that are unnecessary
(and we're trying to address this with a lot of the JNI using code in
the VM at the moment). In this case it is even worse because without
knowing the exception check must be true and so "return NULL" will
always execute, this code has the appearance of being able to continue
if obj == NULL!

Sorry. And thanks.

David
-


91 if (obj == NULL) {
92   free(dcmd_arg_info_array);
93   return NULL;
94 }

or else just replace it with:

109EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

The same for the block here:

  201   if (obj == NULL){
  202 EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
  203   }


Thanks,
David
-


-Harsha

On Tuesday 30 August 2016 09:46 AM, David Holmes wrote:

On 30/08/2016 2:06 PM, Harsha Wardhana B wrote:

Error checking might distract the main flow of code but it would be
far-fetched to call that it obfuscates the code. Ideally error
checking

You claimed macros obfuscate so the same word seemed appropriate. I
don't necessarily equate readability with obfuscation.


could have been made a function (inline if possible) instead of a
macro
but since it is context sensitive in this case (have to free
variables
depending on context) , doing so would obfuscate the code even more.

I tried to separate it into a function and the code looks more
uglier.

I was envisaging something like:

   jstring jname, jdesc,jtype,jdefStr;
   jname = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name);
   EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
   jdesc =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].description);
   EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
   jtype = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type);
   EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
   jdefStr = (*env)->NewStringUTF(env,
dcmd_arg_info_array[i].default_string);
   EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

Of course if this were C++ code instead of C there would be better
techniques for dealing with the free'ing.

Cheers,
David



-Harsha
On Tuesday 30 August 2016 09:26 AM, David Holmes wrote:

On 30/08/2016 1:47 PM, Harsha Wardhana B wrote:

Hi Dmitry,

I am not sure how using macro will help in this context. As far
as I
know, macros must be sparingly used as they are error-prone,
obfuscate
the code and hard to debug. Most of best coding practice for c/c++
(inluding Scott Myers Effective C++ ) advocate using macros only
if it
is absolutely needed.

Macros are used extensively throughout hotspot and the JDK native
code. That isn't to say that all suc

Re: RFR: 8161448: 4 JNI exception pending defect groups in DiagnosticCommandImpl.c

2016-09-06 Thread Harsha Wardhana B

Thanks for the review David.


On Tuesday 06 September 2016 11:35 AM, David Holmes wrote:

Hi Harsha,

On 6/09/2016 3:47 PM, Harsha Wardhana B wrote:

Hi David,

Please find revised webrev.

http://cr.openjdk.java.net/~hb/8161448/webrev.03/


You lost the earlier fix to not throw the exception here:

 202   if (obj == NULL) {
 203   free(dcmd_info_array);
 204   JNU_ThrowOutOfMemoryError(env, 0);
 205   return NULL;
 206   }

but otherwise this all looks fine. No need to see an updated webrev 
with line 204 deleted.


Thanks for your patience and perseverance on this one.

David
-


-Harsha

On Thursday 01 September 2016 03:31 PM, David Holmes wrote:

On 1/09/2016 6:05 PM, Harsha Wardhana B wrote:

Hi David,

On Thursday 01 September 2016 01:14 PM, David Holmes wrote:

Hi Harsha,

Sorry these style issues are proving to be so painful, normally there
would be more direct guidance from an existing team member.

On 30/08/2016 4:51 PM, Harsha Wardhana B wrote:

Hello,

Please find below webrev addressing David's and Dmitry's comments.

http://cr.openjdk.java.net/~hb/8161448/webrev.02/


The idiomatic way we write such macros is as follows:

#define EXCEPTION_CHECK_AND_FREE(x) \
  do { \
if ((*env)->ExceptionCheck(env)) { \
   free(x); \
   return NULL; \
} \
  } while (false)

I am aware of this style but I wasn't aware what style should be used
(BTW last line should be 'while(0)'). I didn't want to do anything 
fancy
and end up sending one more webrev and hence I followed the 
simplest way

to write a multi-line macro.
Now if there isn't anything wrong, I think we should leave it as is
until coding guidelines are put in place. I am facing same problem in
another issue where I have sent multiple webrev fixing only nits. 
It is

turning out to be very painful.


I understand and it is unfortunate that there has not been more
definitive guidance here. But it is better to adopt established style
and get used to using it. If you form is left in then you need spaces
before trailing \ - another style nit, sorry.



---

 109 if (obj == NULL) {
 110 EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
 111 }

Checking both NULL and for exceptions is redundant as previously
pointed out. Either leave this code as it was:
Yes. it may be redundant but it is harmless. Does this really need 
to be

changed?


Yes it breeds confusion to see multiple checks that are unnecessary
(and we're trying to address this with a lot of the JNI using code in
the VM at the moment). In this case it is even worse because without
knowing the exception check must be true and so "return NULL" will
always execute, this code has the appearance of being able to continue
if obj == NULL!

Sorry. And thanks.

David
-



91 if (obj == NULL) {
92   free(dcmd_arg_info_array);
93   return NULL;
94 }

or else just replace it with:

109EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

The same for the block here:

 201   if (obj == NULL){
 202 EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
 203   }


Thanks,
David
-


-Harsha

On Tuesday 30 August 2016 09:46 AM, David Holmes wrote:

On 30/08/2016 2:06 PM, Harsha Wardhana B wrote:
Error checking might distract the main flow of code but it 
would be

far-fetched to call that it obfuscates the code. Ideally error
checking


You claimed macros obfuscate so the same word seemed appropriate. I
don't necessarily equate readability with obfuscation.


could have been made a function (inline if possible) instead of a
macro
but since it is context sensitive in this case (have to free
variables
depending on context) , doing so would obfuscate the code even 
more.


I tried to separate it into a function and the code looks more
uglier.


I was envisaging something like:

  jstring jname, jdesc,jtype,jdefStr;
  jname = 
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].name);

  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jdesc =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].description);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jtype = 
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].type);

  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jdefStr = (*env)->NewStringUTF(env,
dcmd_arg_info_array[i].default_string);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

Of course if this were C++ code instead of C there would be better
techniques for dealing with the free'ing.

Cheers,
David



-Harsha
On Tuesday 30 August 2016 09:26 AM, David Holmes wrote:

On 30/08/2016 1:47 PM, Harsha Wardhana B wrote:

Hi Dmitry,

I am not sure how using macro will help in this context. As far
as I
know, macros must be sparingly used as they are error-prone,
obfuscate
the code and hard to debug. Most of best coding practice for 
c/c++

(inluding Scott Myers Effective C++ ) advocate using macros only
if it
is absolutely needed.


Macros are used extensively throu

Re: RFR: 8161448: 4 JNI exception pending defect groups in DiagnosticCommandImpl.c

2016-09-05 Thread Harsha Wardhana B

Hi David,

Please find revised webrev.

http://cr.openjdk.java.net/~hb/8161448/webrev.03/

-Harsha

On Thursday 01 September 2016 03:31 PM, David Holmes wrote:

On 1/09/2016 6:05 PM, Harsha Wardhana B wrote:

Hi David,

On Thursday 01 September 2016 01:14 PM, David Holmes wrote:

Hi Harsha,

Sorry these style issues are proving to be so painful, normally there
would be more direct guidance from an existing team member.

On 30/08/2016 4:51 PM, Harsha Wardhana B wrote:

Hello,

Please find below webrev addressing David's and Dmitry's comments.

http://cr.openjdk.java.net/~hb/8161448/webrev.02/


The idiomatic way we write such macros is as follows:

#define EXCEPTION_CHECK_AND_FREE(x) \
  do { \
if ((*env)->ExceptionCheck(env)) { \
   free(x); \
   return NULL; \
} \
  } while (false)

I am aware of this style but I wasn't aware what style should be used
(BTW last line should be 'while(0)'). I didn't want to do anything fancy
and end up sending one more webrev and hence I followed the simplest way
to write a multi-line macro.
Now if there isn't anything wrong, I think we should leave it as is
until coding guidelines are put in place. I am facing same problem in
another issue where I have sent multiple webrev fixing only nits. It is
turning out to be very painful.


I understand and it is unfortunate that there has not been more 
definitive guidance here. But it is better to adopt established style 
and get used to using it. If you form is left in then you need spaces 
before trailing \ - another style nit, sorry.




---

 109 if (obj == NULL) {
 110 EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
 111 }

Checking both NULL and for exceptions is redundant as previously
pointed out. Either leave this code as it was:

Yes. it may be redundant but it is harmless. Does this really need to be
changed?


Yes it breeds confusion to see multiple checks that are unnecessary 
(and we're trying to address this with a lot of the JNI using code in 
the VM at the moment). In this case it is even worse because without 
knowing the exception check must be true and so "return NULL" will 
always execute, this code has the appearance of being able to continue 
if obj == NULL!


Sorry. And thanks.

David
-



91 if (obj == NULL) {
92   free(dcmd_arg_info_array);
93   return NULL;
94 }

or else just replace it with:

109EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

The same for the block here:

 201   if (obj == NULL){
 202 EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
 203   }


Thanks,
David
-


-Harsha

On Tuesday 30 August 2016 09:46 AM, David Holmes wrote:

On 30/08/2016 2:06 PM, Harsha Wardhana B wrote:

Error checking might distract the main flow of code but it would be
far-fetched to call that it obfuscates the code. Ideally error
checking


You claimed macros obfuscate so the same word seemed appropriate. I
don't necessarily equate readability with obfuscation.


could have been made a function (inline if possible) instead of a
macro
but since it is context sensitive in this case (have to free 
variables

depending on context) , doing so would obfuscate the code even more.

I tried to separate it into a function and the code looks more 
uglier.


I was envisaging something like:

  jstring jname, jdesc,jtype,jdefStr;
  jname = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jdesc =
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].description);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jtype = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
  jdefStr = (*env)->NewStringUTF(env,
dcmd_arg_info_array[i].default_string);
  EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);

Of course if this were C++ code instead of C there would be better
techniques for dealing with the free'ing.

Cheers,
David



-Harsha
On Tuesday 30 August 2016 09:26 AM, David Holmes wrote:

On 30/08/2016 1:47 PM, Harsha Wardhana B wrote:

Hi Dmitry,

I am not sure how using macro will help in this context. As far 
as I

know, macros must be sparingly used as they are error-prone,
obfuscate
the code and hard to debug. Most of best coding practice for c/c++
(inluding Scott Myers Effective C++ ) advocate using macros only
if it
is absolutely needed.


Macros are used extensively throughout hotspot and the JDK native
code. That isn't to say that all such macro uses are good (we have
bad
code too). However macros make sense where you want to avoid code
duplication and improve readability - as is the case here. It is
quite
common to "hide" error checking logic behind a macro because it is
the
error-checking logic that obfuscates the code.

David
-


-Harsha


On Monday 29 August 2016 02:00 PM, Dmitry Samersoff wrote:

Harsha,

I'm for macro.

You can define a macro right before a place wher

  1   2   >