title: RxJava2/Retrofit2 - Handling null for 204 PUT and DELETE requests
body: <p>So, I am working with an API that is clearly defined and is designed to not return a payload body on <code>DELETE</code> and <code>PUT</code> operations.</p>
  <p>This was acceptable in Rx 0.X and Rx 1.x. Now I'm updating to Rx 2 and having an existential crisis with how I should handle the null values.  The content-length and body are of course null causing:</p>
  <pre><code>java.lang.NullPointerException: Null is not a valid element
     at io.reactivex.internal.queue.SpscLinkedArrayQueue.offer(SpscLinkedArrayQueue.java:68)
     at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.onNext(ObservableObserveOn.java:116)
     at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:63)
  </code></pre>
  <p>in the doOnNext.</p>
  <p>I've seen many people suggest <code>Optional&lt;&gt;</code> but I need to support Java7 as well for use case reasons.  I attempted back-porting but I couldn't quite get it to work.  I also don't want to bloat and import the Guava library for their version.</p>
  <p>I also noticed flatMap may also help me handle this opposed to map and I'm reading up on the differences.</p>
  <p>Currently I have a very crude, OkHttp3 Interceptor that will check the status, check if the payload is empty, and add dummy content which just feels so wrong.</p>
  <p>I've also tried to add a convert factory.</p>
  <p>Can anyone offer suggestions and guide me on what the proper path is? Sure, the API can change, but 204 isn't supposed to have a payload by virtue of it's definition as an HTTP status code.</p>
  <h3>Relevant Dependencies</h3>
  <pre><code>compile('com.squareup.retrofit2:retrofit:2.1.0') {
       exclude module: 'okhttp'
  } 
  compile 'com.squareup.retrofit2:converter-gson:2.1.0'
  compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
  compile 'com.squareup.okhttp3:okhttp:3.5.0'
  compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
  
  compile 'io.reactivex.rxjava2:rxjava:2.0.5'
  compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
  compile 'com.trello.rxlifecycle2:rxlifecycle:2.0.1'
  compile 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1'
  </code></pre>