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

ArrayIndexOutOfBoundsException when parsing properties

XMLWordPrintable

      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;
      }
      

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

              Created:
              Updated:
              Resolved: