Deep copy the tenants to avoid concurrent sort exception
@@ -24,6 +24,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -76,8 +77,10 @@ public class TenantsBase extends PulsarWebResource {
asyncResponse.resume(new RestException(e));
return;
}
- tenants.sort(null);
- asyncResponse.resume(tenants);
+ // deep copy the tenants to avoid concurrent sort exception
+ List<String> deepCopy = new ArrayList<>(tenants);
+ deepCopy.sort(null);
+ asyncResponse.resume(deepCopy);
});
}
