title: Moshi ArrayOutOfBoundsException when adding factory
body: <p>I'm finding this exception related with Moshi sometimes when opening the app:</p>
  
  <pre><code>Caused by java.lang.ArrayIndexOutOfBoundsException: length=33; index=33
         at java.util.ArrayList.add(ArrayList.java:468)
         at com.squareup.moshi.Moshi$Builder.add(Moshi.java:231)
  </code></pre>
  
  <p>We initialise a repository in the BaseApplication which, sometimes, results in the mentioned  crash when initialising Moshi. I'm finding this error in the app reports but I'm not able to reproduce it. Let's jump to the what we have and see if you might have a clue on it.</p>
  
  <p>This factory is used to create Moshi instances, getting the crash when adding KotlinJsonAdapterFactory:</p>
  
  <pre><code>object MyMoshiConverterFactory {
  
      fun create(setup: (Moshi.Builder.() -&gt; Unit)? = null): Converter.Factory {
          val moshi = MoshiUtil.createMoshi()
          setup?.let { moshi.it() }
          moshi.add(KotlinJsonAdapterFactory()) // Here is the crash!
          return MoshiConverterFactory.create(moshi.build())
      }
  }
  </code></pre>
  
  <p>Here we have a class where we have all the converters we use. It really has a lot more of converters, but I've removed a few of them for simplicity:</p>
  
  <pre><code>object MoshiUtil {
  
      private val lazyMoshi by lazy {
          Moshi.Builder().apply {
              add(DateAdapter())
              add(DefaultOnDataMismatchAdapter.newFactory(FeedItem::class.java, null))
              add(SkipListNullValuesAdapter.createFactory(Element::class.java))
              add(SkipListNullValuesAdapter.createFactory(Post::class.java))
              add(SkipListNullValuesAdapter.createFactory(MetadataItem::class.java))
              add(GeoGeometry::class.java, GeometryAdapter())
          }
      }
  
      fun createMoshi() = lazyMoshi
  }
  </code></pre>
  
  <p>And finally, in our BaseApplication, we have something like this:</p>
  
  <pre><code>class BaseApplication {
  
     @Override
      public void onCreate() {
          super.onCreate();
  
          val myService = getMyService(applicationContext)
  
      }
  
      private fun getMyService(appContext: Context): MyService {
         val converterFactory = MyMoshiConverterFactory.create()
  
         return Retrofit.Builder().baseUrl(baseUrl).apply {
                  addConverterFactory(converterFactory)
                  client(okHttpClientBuilder.build())
              }.build().create(MyService::class.java)
          }
      }
   }
  </code></pre>
  
  <p>So, do you see anything that could be causing it? Do you think it might be a concurrency issue happening at startup when the several places in the app are creating the MoshiUtils object at the same time?. Looking forward to hear from you guys, thanks!</p>