This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 247971 - Embedded newlines in VM properties
Summary: Embedded newlines in VM properties
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 4.x
Hardware: PC Windows 8
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-16 09:32 UTC by peterhull90
Modified: 2016-03-15 04:56 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
solution (3.48 KB, patch)
2015-05-01 10:47 UTC, vkhashin
Details | Diff
solution2 (934 bytes, patch)
2015-05-22 17:50 UTC, vkhashin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description peterhull90 2014-10-16 09:32:13 UTC
I have a Java SE 8 project.
I am using the Project Properties/Run/VM Options to set system properties (to be accessed with System.getProperty() )
The VM option box is a multiline edit but if I put properties on separate lines I get them concatenated with a \n between.
Is this a bug? I appreciate entering newlines into properties may be by design.

Test case

Enter the following in VM options:
-Dtest=one
-Dother=two

Using the following code fragment:
public static void main(String[] args) {
        System.out.printf("Property:%s.%n",System.getProperty("test", "empty"));
}

Expected output:
Property:one.

Actual output:
Property:one
-Dother=two.

System details:
Product Version = NetBeans IDE 8.0.1 (Build 201408251540)
Operating System = Windows 8 version 6.2 running on amd64
Java; VM; Vendor = 1.8.0_11
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Comment 1 Tomas Zezula 2014-11-14 17:09:36 UTC
Yes it's a bug.
The new line should be just wrapping.
Comment 2 vkhashin 2015-05-01 10:47:03 UTC
Created attachment 153489 [details]
solution
Comment 3 vkhashin 2015-05-01 10:59:48 UTC
This is good idea to have multiline field on VM options. But saving text format is not trivial task, also customize dialog should be used formatting too. So I have removed opportunity to moving text on next line by pressing "Enter" key. Also I have added focus moving to next field from JTextArea, and added "..." after word "Customize" on the button, because this button invokes dialog.
Comment 4 vkhashin 2015-05-22 17:50:15 UTC
Created attachment 153823 [details]
solution2
Comment 5 vkhashin 2015-05-22 17:53:32 UTC
I think it will not be too hard to store formatting while customizing vm options in dialog. So the solution2 is better.
Comment 6 peterhull90 2015-05-23 10:38:32 UTC
Option 2 is certainly a lot shorter. 

I'm not familiar with the NB code base but will that change affect other parts of the system too?
Comment 7 vkhashin 2015-05-23 18:39:12 UTC
Yes. I know what that code uses in web application project too, maybe in all ant projects. But this changes only replace formatting character "\n" to whitespace and do it for VM options and application arguments.
Comment 8 peterhull90 2015-10-29 09:17:35 UTC
I note that this is still present in 8.1rc2.
Comment 9 Tomas Zezula 2016-03-14 12:23:01 UTC
I am going to integrate the solution #1.

The solution #2 works only when compile on save is enabled. When the compile on save is disabled the copyMultiValue is not used at all, the property is loaded by Ant (including the new lines) the problem will appear again. The solution #2 can be changed
not to remove the new lines before run but remove them when the property is saved into the project.properties. This will work but the formatting will be lost after save of properties. So I think that the solution #1 is better. At least it's much better than the actual state.


Thanks a lot for the patch!
Comment 10 Tomas Zezula 2016-03-14 12:34:32 UTC
Fixed jet-main b3da58e18186.

Again thanks for the patch!
Comment 11 peterhull90 2016-03-14 13:52:47 UTC
And thank you both for solving this one. I look forward to seeing it in the next release!
Comment 12 Quality Engineering 2016-03-15 04:56:48 UTC
Integrated into 'main-silver', will be available in build *201603150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b3da58e18186
User: Tomas Zezula <tzezula@netbeans.org>
Log: #247971:Embedded newlines in VM properties