Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-22530

ArrayIndexOutOfBoundsException when parsing properties

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      a java property value can be wrapped in more than one line:

      name = value\
      split\
      in\
      more\
      lines\
      

      The code in hudson.plugins.android_emulator.util.Utils.parseConfigFile does not take this into account and tries to split every non-empty line at the = char. This causes an ArrayIndexOutOfBoundsException in the above situation.

      proposed fix:

      public static Map<String,String> parseConfigFile(File configFile) throws IOException {
      	FileReader fileReader = new FileReader(configFile);
      	BufferedReader reader = new BufferedReader(fileReader);
      	Properties properties = new Properties();
      	properties.load(reader);
      	reader.close();
      	
      	final Map<String,String> values = new HashMap<String,String>();
      	for (final Entry<Object, Object> entry : properties.entrySet()) {
      		values.put((String) entry.getKey(), (String) entry.getValue());
      	}
      
      	return values;
      }
      

        Attachments

          Activity

          Hide
          orrc Christopher Orr added a comment -

          Do you have an example of an Android emulator config file that shows this problem?
          How was it created?

          Show
          orrc Christopher Orr added a comment - Do you have an example of an Android emulator config file that shows this problem? How was it created?
          Show
          bioparco Stefano Padovan added a comment - see https://github.com/jenkinsci/android-emulator-plugin/pull/35
          Hide
          bioparco Stefano Padovan added a comment - - edited

          i created it like that

          I have many proguard config files to inclue, so instead of having all of them in one big line i have something like:

          proguard.config=\
          ./proguard.cfg:\
          ../library1/proguard.cfg:\
          ../library2/proguard.cfg:\
          ../library3/proguard.cfg
          
          Show
          bioparco Stefano Padovan added a comment - - edited i created it like that I have many proguard config files to inclue, so instead of having all of them in one big line i have something like: proguard.config=\ ./proguard.cfg:\ ../library1/proguard.cfg:\ ../library2/proguard.cfg:\ ../library3/proguard.cfg
          Hide
          orrc Christopher Orr added a comment -

          Ah right, I was forgetting that this code is also used to parse `project.properties` files.

          Show
          orrc Christopher Orr added a comment - Ah right, I was forgetting that this code is also used to parse `project.properties` files.
          Hide
          orrc Christopher Orr added a comment -

          Version 2.11 of the plugin has been released, which fixes this issue.

          Show
          orrc Christopher Orr added a comment - Version 2.11 of the plugin has been released, which fixes this issue.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: xstex
          Path:
          src/main/java/hudson/plugins/android_emulator/util/Utils.java
          src/test/java/hudson/plugins/android_emulator/util/UtilsTest.java
          http://jenkins-ci.org/commit/android-emulator-plugin/1a7a66ef760f5a2da2815f1348ee542df7b40d99
          Log:
          [FIXED JENKINS-22530] Properly parse files with multi-line properties.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: xstex Path: src/main/java/hudson/plugins/android_emulator/util/Utils.java src/test/java/hudson/plugins/android_emulator/util/UtilsTest.java http://jenkins-ci.org/commit/android-emulator-plugin/1a7a66ef760f5a2da2815f1348ee542df7b40d99 Log: [FIXED JENKINS-22530] Properly parse files with multi-line properties.

            People

            • Assignee:
              bioparco Stefano Padovan
              Reporter:
              bioparco Stefano Padovan
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: