Prevent ArrayIndexOutOfBoundsException

This commit switches SingleSelectCapability content to
CopyOnWriteArrayList to prevent ArrayIndexOutOfBoundsException in case
of concurrent updates of boot versions.

Note that there is way to mitigate that in 1.4 with the use of the `sync`
attribute, see gh-251

Closes gh-229
This commit is contained in:
Stephane Nicoll 2016-07-08 11:45:14 +02:00
parent 4145fdc81d
commit a3e902b8f0

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package io.spring.initializr.metadata
import java.util.concurrent.CopyOnWriteArrayList
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
@ -27,7 +29,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
*/
class SingleSelectCapability extends ServiceCapability<List<DefaultMetadataElement>> {
final List<DefaultMetadataElement> content = []
final List<DefaultMetadataElement> content = new CopyOnWriteArrayList<DefaultMetadataElement>()
@JsonCreator
SingleSelectCapability(@JsonProperty("id") String id) {