Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of the configuration file keeps increasing each time ZAP is started with Java 9+ #4194

Closed
thc202 opened this issue Dec 29, 2017 · 3 comments · Fixed by #4808
Closed
Assignees
Milestone

Comments

@thc202
Copy link
Member

thc202 commented Dec 29, 2017

Steps to reproduce the issue:

  1. Run ZAP (with Java 9);
  2. Close ZAP and note the size of the configuration file (config.xml in home dir);
  3. Restart ZAP several times and note that the size of the configuration file keeps increasing.

For example, starting with:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
    <connection>
        <proxyChain/>
    </connection>
</config>

ends up in:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
    <connection>
                                                        
        
        
        
        
        
        <proxyChain/>
                                                    
    
    
    
    
    
    </connection>
</config>

Remarks:
This is related to XML indentation changes in Java 9 (same behaviour with Java 10). The continuous addition of the empty lines around proxyChain seems to be a bug, lines before/after the elements config or connection are properly removed and indented, for example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>


			<config>



    <connection><proxyChain/></connection>




</config>

is changed to:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
    <connection>
        <proxyChain/>
    </connection>
</config>

(But with following saves it starts adding the new lines.)

The workaround is to disable the indentation when saving the configuration file.

ZAP
Version 2.7.0 (and older).

@thc202
Copy link
Member Author

thc202 commented Dec 29, 2017

Labelled as a third-party issue (plan to raise a JDK issue), might worth apply the workaround in the meantime (or if in the end it's not a bug)?
Worth noting that with Apache Commons Configuration 2.x the issue does not happen (the DOM tree is "whitespace cleaned" before being indented).

@alfsb alfsb mentioned this issue Dec 29, 2017
13 tasks
@thc202 thc202 self-assigned this Jul 2, 2018
@thc202 thc202 added this to the 2.8.0 milestone Jul 2, 2018
@thc202 thc202 changed the title Size of the configuration file keeps increasing each time ZAP is started with Java 9 Size of the configuration file keeps increasing each time ZAP is started with Java 9+ Jul 2, 2018
thc202 added a commit to thc202/zaproxy that referenced this issue Jul 2, 2018
Change ZapXmlConfiguration to force the creation of new nodes after
loading the configuration, to ensure just the configuration nodes are
persisted when saved (i.e. without any text nodes that would be indented
again).
Add tests to assert the expected behaviour.

Part of zaproxy#2602.
Fix zaproxy#4194 - Size of the configuration file keeps increasing each time
ZAP is started with Java 9+
@thc202
Copy link
Member Author

thc202 commented Jul 2, 2018

Raised a PR to apply the workaround.

@lock
Copy link

lock bot commented Feb 2, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

2 participants